Set plugin’s version on the command line in Maven 2 - maven-2

I generate default quickstart Maven example, and type mvn checkstyle:checkstyle, it always try to use the lastest SNAPSHOT version. Probably it is wrong in my Nexus server, but how can I set plugin's version on the command line in Maven 2, like 2.5 for checkstyle instead of 2.6-SNAPSHOT?
C:\HelloWorld>mvn checkstyle:checkstyle
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'checkstyle'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-checkstyle-plugin
Reason: Error getting POM for 'org.apache.maven.plugins:maven-checkstyle-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
org.apache.maven.plugins:maven-checkstyle-plugin:pom:2.6-SNAPSHOT
from the specified remote repositories:
nexus (http://localhost:9081/nexus/content/groups/public)
for project org.apache.maven.plugins:maven-checkstyle-plugin
I guess it could be mvn checkstyle:2.5:checkstyle, unfortunately it is not.
Surely if I set build dependance in pom.xml, it will work, but I want to see how command line can work.

If you don't want to run the latest version of a plugin installed in your local repository, you need to set the version number. And for that, you need to specify a fully-qualified goal in the form of:
mvn groupID:artifactID:version:goal
So in your case:
mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle

mvn org.apache.maven.plugins:maven-site-plugin:3.7.1:site

My experience with a newer version of maven(3.3.9) is slightly different. If I'm not running maven in offline mode, it will ALWAYS go for a remote repo regardless of what I have in the local one.
And if it finds a newer version(based on maven-metadata.xml), it will download and use that one. What's more, it will scan multiple repos simultaneously:
[INFO] ------------------------------------------------------------------------
[DEBUG] Resolving plugin version for com.phoenixnap.oss:springmvc-raml-plugin
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in local (/home/yuranos/.m2/repository)
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/libs-milestone
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/milestone
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/snapshot
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/libs-milestone
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/milestone
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/snapshot
Downloading: https://repo.spring.io/libs-milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.spring.io/snapshot/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.spring.io/milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
Downloaded: https://repo.maven.apache.org/maven2/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml (2 KB at 1.0 KB/sec)
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
Downloaded: https://repo.spring.io/libs-milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml (2 KB at 0.9 KB/sec)
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in spring-snapshots (https://repo.spring.io/snapshot)
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in spring-milestones-libs (https://repo.spring.io/milestone)
What's more, maven seems to know how to compare several metadata files and select the very latest version of the artifact.
Maven makes use of Aether to resolve dependencies, based on what I see in resolver-status.properties:
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Mon Feb 19 23:41:24 EET 2018
maven-metadata-spring-milestones.xml.lastUpdated=1519076484366
maven-metadata-spring-snapshots.xml.error=
maven-metadata-central.xml.lastUpdated=1519076484205
maven-metadata-spring-snapshots.xml.lastUpdated=1519076484107
maven-metadata-spring-milestones-libs.xml.lastUpdated=1519076484105
maven-metadata-spring-milestones-libs.xml.error=

You can also use:
mvn {your groupId}:{your artifactId}:{your version}:{your goal}

Related

Automation test report issues with JENKINS/MAVEN/ECLIPSE

I am facing issues while generating reports after successful build using maven in jenkins.
First, I have created java code into my local machine using eclipse.
Second, After creating the code I converted it to the Maven and completed all required setup of pom.xml file inside jenkins using Maven.
Third, I ran the script it gives me the success response.
Below, it is my maven success build result logs.
Started by user jenkin
Building in workspace /var/lib/jenkins/workspace/TestProject
Parsing POMs
Modules changed, recalculating dependency graph
Established TCP socket on 35275
[TestProject01] $ java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven1/boot/plexus-classworlds-2.5.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven1/conf/logging jenkins.maven3.agent.Maven35Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven1 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.27.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12.jar 35275
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /home/user/Documents/eclipse-workspace/TestProject01/pom.xml clean install
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[INFO]
[INFO] ------------------< TestProject01:TestProject01 >-------------------
[INFO] Building TestProject01 0.0.1-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # TestProject01 ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # TestProject01 ---
[INFO] Installing /home/user/Documents/eclipse-workspace/TestProject01/pom.xml to /var/lib/jenkins/.m2/repository/TestProject01/TestProject01/0.0.1-SNAPSHOT/TestProject01-0.0.1-SNAPSHOT.pom
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO]
[INFO] BUILD SUCCESS
[INFO] Total time: 2.821 s
[INFO] Finished at: 2019-02-05T19:09:16+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /home/user/Documents/eclipse-workspace/TestProject01/pom.xml to TestProject01/TestProject01/0.0.1-SNAPSHOT/TestProject01-0.0.1-SNAPSHOT.pom
/home/user/Documents/eclipse-workspace/TestProject01/pom.xml is not inside /var/lib/jenkins/workspace/TestProject/home/user/Documents/eclipse-workspace/TestProject01/; will archive in a separate pass
channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level /home/user/Documents/eclipse-workspace/TestProject01/test-output to /var/lib/jenkins/jobs/TestProject/htmlreports/HTML_20Report
Finished: SUCCESS
Now, The issue is I do not know how can I check if all testcases covered with success. Here, HTML report been generated but it stays the same after every build success which creating lot of confusion.
Please help!!!!!!!!

Not able to execute scripts from Jenkins although working fine locally & via command line

I am Not able to run scripts from Jenkins. How ever working fine from Command line & Local. I am within office network. Getting Below Error. I don't understand why Jenkins is trying to download Maven plugin? I am new to Jenkins. Any suggestion will be appretiated.
[INFO] ------------------------< Test:Junit-Demo >-------------------------
[INFO] Building Junit-Demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.695 s
[INFO] Finished at: 2018-04-11T14:29:52-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.68.215] failed: Connection timed out: connect -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding="UTF-8"
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Maven, triggered by Jenkins, downloads the maven-clean-plugin as part of its normal execution. This happened on your location machine in the first run and was then cached in ~/.m2/.
Your Jenkins build agent, however, cannot connect to the server from which maven downloads artifacts:
Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.68.215] failed: Connection timed out: connect
Make sure that there is no firewall involved blocking these connections or configure Jenkins to use a local artifact repository (like Nexus or Artifactory).
Missing some info to fully know what's wrong.
To use maven in Jenkins you have to install the jenkins maven plugin and call the binary in your Jenkins file.
Did you have to do any maven configuration for your local set up?
ie inside ~/.m2 is usually where you would set up your account for nexus credentials inside settings.xml.
You would have to do this same config on your jenkins machine, either in the Jenkins user account's ~/.m2 or inside the maven plugin folder.

Cloudbees Deploy failure due to NullPointerException in RunTargetImpl.getClickStackConfigMap

I've juste created an new app in cloudbees with clickStart "Jetty 9 Embedded App" and when Jenkins build the generated project(without any change) I get this error.
Can you help me to find the problem origin ?
thanks.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.919s
[INFO] Finished at: Fri Sep 27 06:49:44 EDT 2013
[INFO] Final Memory: 16M/40M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /scratch/jenkins/workspace/code-elevator-2/pom.xml to /home/flagadajones/hudson_home/jobs/code-elevator-2/modules/localdomain.localhost$jetty9-embedded-clickstart/builds/2013-09-27_10-48-58/archive/localdomain.localhost/jetty9-embedded-clickstart/0.1-SNAPSHOT/jetty9-embedded-clickstart-0.1-SNAPSHOT.pom
[JENKINS] Archiving /scratch/jenkins/workspace/code-elevator-2/target/jetty9-embedded-clickstart-0.1-SNAPSHOT.jar to /home/flagadajones/hudson_home/jobs/code-elevator-2/modules/localdomain.localhost$jetty9-embedded-clickstart/builds/2013-09-27_10-48-58/archive/localdomain.localhost/jetty9-embedded-clickstart/0.1-SNAPSHOT/jetty9-embedded-clickstart-0.1-SNAPSHOT.jar
[JENKINS] Archiving /scratch/jenkins/workspace/code-elevator-2/target/jetty9-embedded-clickstart-0.1-SNAPSHOT-jar-with-dependencies.jar to /home/flagadajones/hudson_home/jobs/code-elevator-2/modules/localdomain.localhost$jetty9-embedded-clickstart/builds/2013-09-27_10-48-58/archive/localdomain.localhost/jetty9-embedded-clickstart/0.1-SNAPSHOT/jetty9-embedded-clickstart-0.1-SNAPSHOT-jar-with-dependencies.jar
Waiting for Jenkins to finish collecting data
channel stopped
[cloudbees-deployer] Deploying as (jenkins) to the flagadajones account
[cloudbees-deployer] Deploying code-elevator-2
[cloudbees-deployer] Resolved from archived artifacts as /home/flagadajones/hudson_home/jobs/code-elevator-2/modules/localdomain.localhost$jetty9-embedded-clickstart/builds/2013-09-27_10-48-58/archive/localdomain.localhost/jetty9-embedded-clickstart/0.1-SNAPSHOT/jetty9-embedded-clickstart-0.1-SNAPSHOT-jar-with-dependencies.jar
com.cloudbees.plugins.deployer.exceptions.DeployException
at com.cloudbees.plugins.deployer.impl.run.RunEngineImpl.newDeployActor(RunEngineImpl.java:150)
at com.cloudbees.plugins.deployer.impl.run.RunEngineImpl.newDeployActor(RunEngineImpl.java:52)
at com.cloudbees.plugins.deployer.engines.Engine.process(Engine.java:173)
at com.cloudbees.plugins.deployer.engines.Engine.perform(Engine.java:112)
at com.cloudbees.plugins.deployer.DeployPublisher.perform(DeployPublisher.java:103)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:812)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:784)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:957)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:734)
at hudson.model.Run.execute(Run.java:1600)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:485)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.NullPointerException
at com.cloudbees.plugins.deployer.impl.run.RunTargetImpl.getClickStackConfigMap(RunTargetImpl.java:256)
at com.cloudbees.plugins.deployer.impl.run.RunEngineImpl$DeployFileCallable.<init>(RunEngineImpl.java:297)
at com.cloudbees.plugins.deployer.impl.run.RunEngineImpl.newDeployActor(RunEngineImpl.java:141)
... 13 more
Build step 'Deploy applications' marked build as failure
Finished: FAILURE
The clickstart generates an invalid configuration for the deployer plugin. Remove the target from the deploy publisher and add it back again. The issue is that the Maven artifact selector is not selected and the clickstart has fed incorrect configuration for the target, which means that you can't just select the maven artifact selector, instead you need to remove the target and add it back again...
Nuts I know, I shall be chastising the clickstart maintainers on Monday rest assured ;-)

error in deploying jar to remote repository in maven

i am trying to deploy a jar file from my local machine to a remote machine which has an artifactory. I tried the following command :
mvn deploy:deploy-file -DgroupId=<some-id>
-DartifactId=<some-artifact>
-Dversion=<version>
-Dpackaging=jar
-Dfile=<path to the file in my local system>
-Durl=http://<ip of remote machine>:<port>/artifactory/repo/
-DrepositoryId=<artifactory -id in remote machine>
but on executing it gives error that:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] -----------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] -----------------------------------------------------------------------
[INFO] -----------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] -----------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'deploy:
ploy-file'
[0] Inside the definition for plugin 'maven-deploy-plugin' specify the following
:
<configuration>
...
<url>VALUE</url>
</configuration>
-OR-
on the command line, specify: '-Durl=VALUE'
As i am specifying the value for Durl in my command why am i still getting this error?
How to resolve this?
The maven version is 2.2.1
Thanks.
Answered in comments:
Not sure about the Maven error itself, but I did notice that the
deployment URL points to Artifactory's "/repo" repository (which is a
global virtual aggregator of all the repositories in the instance);
since it's a virtual repository, one cannot deploy to it; you should
point the URL to one of Artifactory's local repositories
(libs-release-local, etc.). – noamt Jan 20 '12 at 8:44
i changed it to local repo name but still same error – pranay Jan 20
'12 at 13:02
yes i got it wokring now..actually was putting the wrong url ..thanks
a lot – pranay Jan 25 '12 at 6:33

Maven : Parent project not resolved, transitive dependencies not used for compiling

After searching and trying a lot of things I need a Maven maven :)
So, my problem is that on my development box (which is Windows 2003) I can build my maven project, but on the Bamboo server (x86_64 x86_64 x86_64 GNU/Linux) it fails because one of the modules doesn't have a library and the compiling doesn't find a class.
The class is found in a transitive dependency, dependency that it seems to me that is not resolved.
I've run the command "mvn -X clean install" on both boxes and compared the output.
The only change I think it's relevant is
On dev-box
[DEBUG] Retrieving parent-POM: pl.com.abg.iacsro:sapscndp-claimprocessing:pom:1.0-SNAPSHOT for project: pl.com.abg.iacsro:sapscndp-claimprocessing-api:jar:DEV2010 from the repository.
On Bamboo box
[DEBUG] Retrieving parent-POM: pl.com.abg.iacsro:sapscndp-claimprocessing:pom:1.0-SNAPSHOT for project: null:sapscndp-claimprocessing-api:jar:DEV2010 from the repository.
It seems to me that maven doesn't resolve the parent of the module, because later in the build process I've seen (on Bamboo box)
[WARNING] POM for 'pl.com.abg.iacsro:sapscndp-claimprocessing-api:pom:DEV2010:provided' is invalid.
Its dependencies (if any) will NOT be available to the current build.
[DEBUG] Reason: Failed to validate POM for project pl.com.abg.iacsro:sapscndp-claimprocessing-api at Artifact [pl.com.abg.iacsro:sapscndp-claimprocessing-api:pom:DEV2010:provided]
Validation Errors:
[DEBUG] 'dependencies.dependency.version' is missing for pl.com.abg.iacsro:systemcore-jobs-api:jar
[DEBUG] 'dependencies.dependency.version' is missing for pl.com.abg.iacsro:workflow-crossconflictresolution-api:jar
[DEBUG] 'dependencies.dependency.version' is missing for pl.com.abg.iacsro:iacs-commons-objectfactory:jar
[DEBUG] 'dependencies.dependency.version' is missing for ro.siveco.iacsro:farmerregistry-api:jar
I've also found this
[WARNING] POM for 'pl.com.abg.iacsro:sapscndp-claimprocessing-api:pom:DEV2010:provided' is invalid.
but I've checked and validated myself the pom of the dependency against the xsd, so the pom is valid.
Do you have any idea how to resolve this ?
Many thanks!
P.S. : In case maybe I've overlooked something, here's the full listing from the Bamboo box http://dl.dropbox.com/u/402296/install.txt
When I see such an entry:
[DEBUG] Connecting to repository: 'Artifactory-internal-repository' with url: 'http://192.168.0.59:8081/artifactory/repo'.
Downloading: http://192.168.0.59:8081/artifactory/repo/pl/com/abg/iacsro/onthespotcheck/1.0-SNAPSHOT/onthespotcheck-1.0-SNAPSHOT.pom
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Artifact resolved
[WARNING] POM for 'pl.com.abg.iacsro:onthespotcheck-checks-api:pom:DEV2009_2:provided' is invalid.
I'm tempted to ask if there is anything particular to say about onthespotcheck-1.0-SNAPSHOT.pom?
As a side note, you have a bunch of:
for project: null:artifactId:version
that I find pretty weird. Why is the groupId null? Anything worth to mention about your pom?