Jenkins not able to pick Test cases - jenkins

I am using an maven project with TestNG, project contains 1 testcase
When I run maven manually using cmd, test suite gets executed properly.
mvn test -e
I don't get any errors when I do it manually.
I have configured a jenkins maven project.
I have correctly configured maven & jdk.
I have correctly passed path to pom.xml
Goal: test -e
Jenkins somehow is not able to run my test case.
It doesn't find my test cases.
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Jenkin_Demo_Project</groupId>
<artifactId>Jenkin_Demo_Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>false</testFailureIgnore>
<systemProperties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
</dependencies>
</project>
TestNG.xml:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Example test run">
<test name="StartTest">
<classes>
<class name="TestCase.StartApplication"/>
</classes>
</test>
</suite>
Please tell me what am i missing, Why jenkin's not able to pick my test case, though manually its working fine.
I have jenkins installed on my local system.
Image of jenkin project :
Jenkins Console Output :
Started by user neha1
Building in workspace C:\Program Files (x86)\Jenkins\workspace\GitMavenProject
> C:\Program Files (x86)\Git\cmd\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> C:\Program Files (x86)\Git\cmd\git.exe config remote.origin.url https://github.com/nehabedi/Repo1.git # timeout=10
Fetching upstream changes from https://github.com/nehabedi/Repo1.git
> C:\Program Files (x86)\Git\cmd\git.exe --version # timeout=10
Setting http proxy: 172.18.65.22:80
> C:\Program Files (x86)\Git\cmd\git.exe -c core.askpass=true fetch --tags --progress https://github.com/nehabedi/Repo1.git +refs/heads/*:refs/remotes/origin/*
> C:\Program Files (x86)\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> C:\Program Files (x86)\Git\cmd\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision c63d32391414a2a8368c74fb34733fafc66fc5f6 (refs/remotes/origin/master)
> C:\Program Files (x86)\Git\cmd\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files (x86)\Git\cmd\git.exe checkout -f c63d32391414a2a8368c74fb34733fafc66fc5f6
> C:\Program Files (x86)\Git\cmd\git.exe rev-list c63d32391414a2a8368c74fb34733fafc66fc5f6 # timeout=10
Parsing POMs
[Jenkin_Demo_Project] $ "C:\Program Files\Java\jdk1.8.0_74/bin/java" -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;D:\apache-maven-3.2.5\boot\plexus-classworlds-2.5.2.jar;D:\apache-maven-3.2.5/conf/logging" jenkins.maven3.agent.Maven31Main D:\apache-maven-3.2.5 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-2.53.3.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar" 52804
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\pom.xml clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Jenkin_Demo_Project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # Jenkin_Demo_Project ---
[INFO] Deleting C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Jenkin_Demo_Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # Jenkin_Demo_Project ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Jenkin_Demo_Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # Jenkin_Demo_Project ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.14:test (default-test) # Jenkin_Demo_Project ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

At a glance this looks oke. Wondering, is the location of testng.xml right? I would also try to scope of testng dependency to test, like
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<test>
</dependency>

Related

Jenkins not able to run soapUI test: No test to run

I am running SoapUI test from Jenkins.
I have placed my soapui-project.xml file placed in same directory where my pom.xml is placed which is in master in bitbucket. Jenkins is able to pick all changes in my pom.xml. but not running tests.
Jenkin log says "no test to run"
I tried adding source and placing my soapui-project.xml file in src/main/resources keeping below properties.
<sourceDirectory>src/main/resources</sourceDirectory>
<testSourceDirectory>src/main/resources</testSourceDirectory>
but behavior not changed.
my pom.xml is as below
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Test soapui</name>
<groupId>RestCountriesInfo</groupId>
<artifactId>com.example.soapuitests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>SOAPUITesting</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<!-- <sourceDirectory>src</sourceDirectory>
<testSourceDirectory>src/main/resources</testSourceDirectory>
-->
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.5.0</version>
<dependencies>
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>forms</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>RestCountriesInfo</id>
<configuration>
<projectFile>RestCountriesInfo-soapui-project.xml</projectFile>
<outputFolder>src/main/resources/report</outputFolder>
<testSuite>DEV</testSuite>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<printReport>true</printReport>
<testFailIgnore>true</testFailIgnore>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here are Jenkins logs
Posting build status of INPROGRESS to SWC Bitbucket for commit id [d95035dda15d279d5622478d8dbd178591e1f66a] and ref 'refs/heads/master'
Failed to post build status, additional information: timeout
[API_TEST] $ /opt/maven/bin/mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< RestCountriesInfo:com.example.soapuitests >--------------
[INFO] Building Test soapui 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # com.example.soapuitests ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # com.example.soapuitests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # com.example.soapuitests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # com.example.soapuitests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /opt/jenkins/workspace/Feature/Dev/API_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # com.example.soapuitests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # com.example.soapuitests ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.454 s
[INFO] Finished at: 2022-11-29T12:47:34+11:00
[INFO] ------------------------------------------------------------------------
Any idea why Jenkins not able to execute my tests.
Notice in your log output that the soapui-maven-plugin never got run.
You have two options:
In Jenkins you can specify the target phase: com.smartbear.soapui:soapui-maven-plugin:5.5.0:test, as per official documentation. But as you can see this contains the plugin version in the command, which is probably undesirable.
You can add a <phase> that you want to run the soapui plugin in; probably test. This goes in your <configuration> block. Note that <goal> and <phase> are not the same thing; they each configure something different, even thought they might have the same target. More information is available in official documentation.
As a side note, the <packaging> for this project is not jar - there is no compile phase. It is just pom.

Custom Maven packaging, transitive dependencies aren't included

I'm playing around with a custom Maven 3 packaging plugin for some non-java artifacts, and having an issue getting transitive dependencies to work. I've got three projects defined, model, model-impl, and cli, with dependencies like this:
cli
model-impl
model
My custom lifecycle plugins are being called in each project, and I can successfully build model and model-impl. For each of those projects, the expected artifacts are being stored in my local repository. cli however is failing because I don't get model as a dependency in my Mojo. I'm not completely sure that this is a problem in my code though, because even using mvn dependency:dependency-tree doesn't show the full dependency hierarchy:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.corp.nodes:myproj-cli >-----------------------
[INFO] Building myproj Test 1.0.0-SNAPSHOT
[INFO] --------------------------------[ myproj ]--------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproj-cli ---
[INFO] com.corp.nodes:myproj-cli:myproj:1.0.0-SNAPSHOT
[INFO] \- com.corp.:myproj-model-impl:myproj:1.0.0-SNAPSHOT:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Here I would have expected that I see a tree with three levels for each of the projects.
Here's the components.xml defined in my custom plugin:
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>myproj</role-hint>
<implementation>
org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
</implementation>
<configuration>
<phases>
<initialize>com.corp.maven:myproj-plugin:unpackageDependencies</initialize>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>com.corp.maven:myproj-plugin:compile</compile>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>com.corp.maven:myproj-plugin:package</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</configuration>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>myproj</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>myproj</type>
<extension>myproj</extension>
<packaging>myproj</packaging>
<addedToClasspath>true</addedToClasspath>
<includesDependencies>true</includesDependencies>
</configuration>
</component>
</components>
</component-set>
All of the project POMs have their packaging set to myproj, and all of the dependencies have their type set to myproj. Here's the pom for the cli project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.corp.arthur.nodes</groupId>
<artifactId>myproj-cli</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>myproj</packaging>
<name>myproj Test</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.corp.arthur</groupId>
<artifactId>myproj-model-impl</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>myproj</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.corp.maven</groupId>
<artifactId>myproj-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
The POM for the impl project looks similar. Any idea's what I'm missing?
Finally figured out what was going on by tracing through the source for the DefaultDependencyCollector class. Turns out I needed to set includesDependencies in my components.xml to false. What was happening is the dependency collector saw that flag was true, meaning the dependencies were included in the artifact, and so didn't recurse through them. With it set to false, it does recurse, and I get the expected behavior.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.corp.nodes:myproj-cli >------------------
[INFO] Building myproj Test: CLI Node 1.0.0-SNAPSHOT
[INFO] --------------------------------[ myproj ]--------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproj-cli ---
[INFO] com.corp.nodes:myproj-cli:myproj:1.0.0-SNAPSHOT
[INFO] \- com.corp:myproj-model-impl:myproj:1.0.0-SNAPSHOT:compile
[INFO] \- com.corp:myproj-model:myproj:1.0.0-SNAPSHOT:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I've been struggling with a similar problem while trying to include my android lib via maven to my another project. My research has shown that library's pom file isn't included in maven library for some cases like mine was - I had an .aar file. Hence, your project build system doesn't know anything about these transitive dependencies. The solution for me was to manually point them in in my Gradle file. You can familiarize with this more concretely in this topic.

No plugin found for prefix 'docker' in the current project and in the plugin groups

deploy Spring Cloud project with docker, some code in the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
</plugins>
</build>
when i execute the command: mvn package docker:build, it throws the above errors:
Downloaded: http://3.2.4.2:8888/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 5.7 KB/sec)
Downloaded: http://3.2.4.2:8888/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 7.3 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] eureka-server ...................................... SUCCESS [ 26.279 s]
[INFO] service-1 ......................................... SUCCESS [ 14.649 s]
[INFO] demo1 ........................................... FAILURE [ 2.850 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.535 s
[INFO] Finished at: 2017-11-15T14:28:05+08:00
[INFO] Final Memory: 47M/532M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'docker' in the current project
and in the plugin groups [org.sonatype.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/../Repository), nexus (http://3.2.4.2:8888/repository/maven-public/)]
how to solve it?
add the below code to your maven conf/setting.xml:
<pluginGroups>
<pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
if you want to get more detail, pls refer to https://github.com/spotify/docker-maven-plugin/issues/322
If you are using dockerfile maven plugin, you need to change docker:build to
dockerfile:build and docker:push to dockerfile:push
For me worked in a different way, if you follow the maven plugin pattern {prefix}-maven-plugin... which in this case is dockerfile-maven-plugin, you should be able to run it with: mvn package dockerfile:build.
I'm using Maven: 3, Spring Boot 2 and Docker maven plugin 1.3.4

How to deploy artifacts to Maven Repository (JFrog artifactory) through Jenkins Build Offline?

Context:
I am trying to do a simple build (not through a pipeline job) on a maven project through Jenkins which is installed in an offline environment (no internet connection). The build happens successfully and I see the HelloMaven.jar successfully deployed to JFrog artifactory which is again installed offline.
Problem:
But the overall Jenkins build fails with the reason
"Build Step:Deploy artifacts to Maven Repository changed build result to FAILURE"
The Jenkins build console output is mentioned as below:
Started by user admin
Building in workspace C:\Users\dipakrai\.jenkins\workspace\HelloMaven
Updating https://myownlaptop/svn/HelloMavenDemo/HelloMaven at revision '2017-07-13T11:51:44.844 +0530'
Using sole credentials admin/****** (SVN) in realm <https://myownlaptop.com:443> VisualSVN Server
At revision 6
No changes for https://myownlaptop.com/svn/HelloMavenDemo/HelloMaven since the previous build
Parsing POMs
Established TCP socket on 62532
[HelloMaven] $ "C:\Program Files\Java\jdk1.8.0_65/bin/java" -cp "C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-agent-1.11.jar;C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\boot\plexus-classworlds-2.4.jar" org.jvnet.hudson.maven3.agent.Maven3Main "C:\Program Files\Apache Software Foundation\apache-maven-3.0.3" C:\Users\dipakrai\.jenkins\war\WEB-INF\lib\remoting-3.7.jar C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-1.11.jar C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.11.jar 62532
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml deploy
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloMaven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- buildnumber-maven-plugin:1.3:create (default) # HelloMaven ---
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven
[INFO] Storing buildNumber: null at timestamp: 1499926911471
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # HelloMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\dipakrai\.jenkins\workspace\HelloMaven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # HelloMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # HelloMaven ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) # HelloMaven ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # HelloMaven ---
[INFO] Installing C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\HelloMaven.jar to C:\Users\dipakrai\.m2\repository\net\roseindia\maven\quickstart\HelloMaven\1.0-SNAPSHOT\HelloMaven-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml to C:\Users\dipakrai\.m2\repository\net\roseindia\maven\quickstart\HelloMaven\1.0-SNAPSHOT\HelloMaven-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # HelloMaven ---
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar (4 KB at 18.4 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom (4 KB at 8.6 KB/sec)
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml (784 B at 16.3 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml (298 B at 1.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.064s
[INFO] Finished at: Thu Jul 13 11:51:55 IST 2017
[INFO] Final Memory: 15M/247M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml to net.roseindia.maven.quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-SNAPSHOT.pom
[JENKINS] Archiving C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\HelloMaven.jar to net.roseindia.maven.quickstart/HelloMaven/1.0-20170713.062154-1/HelloMaven-1.0-20170713.062154-1.jar
Used promoter class: org.jenkinsci.plugins.artifactpromotion.NexusOSSPromotor
channel stopped
Local repository path: [C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\local-repo]
Started with promotion
Get Artifact and corresponding POM
Checking if POM already exists in releaserepo
POM doesn't exist in release repo, it will be deployed
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
##################################################]
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml ( at 31.9 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.jar
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.jar ( at 17.5 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.pom
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.pom ( at 9.3 KB/sec)
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
##################################################]
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml ( at 7.3 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml ( at 10.5 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml ( at 2.1 KB/sec)
Skipping deletion of artifact from source repo as requested by user
Maven RedeployPublisher use remote maven settings from : C:\Users\dipakrai/.m2/settings.xml
[INFO] Deployment in http://localhost:8081/artifactory/repo1 (id=ArtifactID,uniqueVersion=true)
Deploying the main artifact HelloMaven-1.0-20170713.062154-1.jar
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml (787 B at 1.9 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom
ERROR: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:193)
at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
at hudson.model.Run.execute(Run.java:1760)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:420)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.put(BasicRepositoryConnector.java:274)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
... 14 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:631)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:553)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:535)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:529)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:509)
at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
... 16 more
[INFO] Deployment failed after 0.55 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Finished: FAILURE
The pom.xml file entry for my HelloMaven project is as below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.roseindia.maven.quickstart</groupId>
<artifactId>HelloMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HelloMaven</name>
<scm>
<connection>scm:svn:https://mylaptop/svn/myRepo/</connection>
</scm>
<build>
<finalName>HelloMaven</finalName>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
<webResources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}</directory>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>-->
<distributionManagement>
<repository>
<id>artifactory</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</distributionManagement>
</project>
The settings.xml file for MAVEN m2 folder is as below:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--<localRepository>C:\Users\dipakrai\.m2\repository</localRepository>-->
<pluginGroups>
<!-- Nothing is present now-->
</pluginGroups>
<proxies>
<!-- Nothing is present now-->
</proxies>
<servers>
<server>
<username>admin</username>
<password>{v2akWC7LO8QHuoPFXESAScpHLzTFzcIKG054oyvz/nc=}</password>
<id>central</id>
</server>
<server>
<username>admin</username>
<password>{v2akWC7LO8QHuoPFXESAScpHLzTFzcIKG054oyvz/nc=}</password>
<id>snapshots</id>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<url>http://localhost:8081/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifadeploymentRepoctory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>HelloMaven-snapshot</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
For the last four days I have taken trying to fix the issue and went through a number of posts as this Infrastructure with maven, Jenkins, Nexus. I am not sure where I am going wrong.
Any clue would be extremely grateful.
The answer above by #VonC helped me to fix the issue. The server id I have entered in the settings.xml file and the Jenkins artifactory configuration is a mismatch.
I made the following changes as listed below.
First, I updated my Jenkins artifactory configuration as shown below. The REPOSITORY ID musty exactly match the server id mentioned in the settings.xml file:
<server>
<username>admin</username>
<password>AP447H6DXXJW6WW54BvNBorau5s</password>
<id>artifactory</id>
</server>
And also the repository id entry further below in the settings.xml file must be the same as server id above:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>artifactory</id>
<name>myproject-release</name>
<url>http://localhost:8081/artifactory/repo2</url>
</repository>
Secondly, though I haven't tested this explicitly but it must be that way:
The entry in the project pom.xml file should also be having the same id for repository where the distribution binary has to be released (in this case, the artifactory).
<distributionManagement>
<repository>
<id>artifactory</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</distributionManagement>
Alternatively, since you would have integrated the JFrog artifactory with Jenkins you need not configure the "Deploy artifacts to Maven repository". Instead the below configuration as shown in the screen-shot would deploy your project artifact to the artifactory.
"Deploy artifact to artifactory"
Check what mvn help:effective-settings returns in order to double-check your user/password is indeed used.
Double check the username/password match the ones displayed here, where Atifactory generates the encrypted password.
Finally, following this post, avoid "central" as an id.

Jenkins : Run Multiple Dependencies Maven Project

I have 3 maven projects. Project1, Project2 & Project3.
Project3 depends on Project1 & Project2 and Project2 depends on Project1.
For this I have added this in Project2 pom.xml file
<modelVersion>4.0.0</modelVersion>
<groupId>Project2</groupId>
<artifactId>Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>Project1</groupId>
<artifactId>Project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
My pom.xml for Project3 is -
<modelVersion>4.0.0</modelVersion>
<groupId>Project3</groupId>
<artifactId>Project3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>Project1</groupId>
<artifactId>Project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>Project2</groupId>
<artifactId>Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
In the project 3 I have added testng.xml file to run the test. Now If I run this testng.xml file then all my test cases are running successfully.
I have included testng.xml file in the pom file below dependencies to run testng test using maven -
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<!-- Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>Tng1.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Compiler plugin configures the java version to be used for compiling the code -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Even these tests are running when I am trying to run this using Maven Test. But when I tried to run this using jenkins then it fails and shows below error.
[WARNING] The POM for Project1:Project1:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for Project2:Project2:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.476 s
[INFO] Finished at: 2015-08-25T15:16:56+05:30
[INFO] Final Memory: 13M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Project3: Could not resolve dependencies for project Project3:Project3:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: Project1:Project1:jar:0.0.1-SNAPSHOT, Project2:Project2:jar:0.0.1-SNAPSHOT: Could not find artifact Project1:Project1:jar:0.0.1-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
Please Help !!!

Resources