My java/maven project called "testproject" is hooked up with my jenkins and nexus repo:
My pom.xml looks like:
....
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>nexus</id>
<name>RepositoryProxy</name>
<url>http://nexus:8080/nexus/content/repositories/releases</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>nexus</id>
<name>RepositoryProxy</name>
<url>http://nexus:8080/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
......
In my jenkins set up, I have:
Build - maven3 - clean deploy
As expected, jenkins uploads the artifact to Nexus.Look at the console output from jenkins build, as below:
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ testproject ---
[INFO] Building jar: /var/lib/jenkins/workspace/testproject/target/testproject-0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ testproject ---
[INFO] Installing /var/lib/jenkins/workspace/testproject/target/testproject-0.1-SNAPSHOT.jar to /var/lib/jenkins/.m2/repository/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1- SNAPSHOT.jar
[INFO] Installing /var/lib/jenkins/workspace/testproject/pom.xml to /var/lib/jenkins/.m2/repository/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ testproject ---
Downloading: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/maven-metadata.xml (1012 B at 28.2 KB/sec)
Uploading: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1-20120509.161644-74.jar
Uploaded: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1-20120509.161644-74.jar (47 KB at 748.5 KB/sec)
Uploading: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1-20120509.161644-74.pom
Uploaded: http://nexus:8080/nexus/content/repositories/snapshots/com/dummy/testproject/0.1-SNAPSHOT/testproject-0.1-20120509.161644-74.pom (6 KB at 149.3 KB/sec)
Questions are:
Given the version I specified in pom.xml is
<version>0.1-SNAPSHOT</version>
How come jenkins upload testproject-0.1-20120509.161644-74.jar to Nexus? where is 20120509.161644-74 stuff coming from?
if the timestamp 20120509.161644-74 is generated by jenkins prior to uploading, can I configure the format of it? I want to have something like testproject-01-${timestamp}-${reversionId}.jar
First load of the Nexus repository manager admin console. The first thing you need to do is provide the Maven group, artifact, version and packaging attributes for the deployment artifact you are about to upload. After doing so, use the Select Artifacts to Upload button to browse to the JAR file of interest.
The maven deploy plugin page tells that "By default, when a snapshot version of an artifact is deployed to a repository, a timestamp is suffixed to it". So, it is created by the plugin when you call mvn deploy
.
I don't know if what you want in 2) is possible. I think it might cause some trouble for maven.
When you use maven with SNAPSHOT dependencies, the timestamps are used to check for the most recent version of a SNAPSHOT. Changing the format of the snapshots would probably cause this mechanism to fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With