问题描述
我的java/maven项目"testproject"与我的jenkins和nexus回购挂钩:
My java/maven project called "testproject" is hooked up with my jenkins and nexus repo:
我的pom.xml看起来像:
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
按预期,jenkins将工件上传到Nexus.查看jenkins build的控制台输出,如下所示:
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)
问题:
鉴于我在pom.xml中指定的版本为
Given the version I specified in pom.xml is
<version>0.1-SNAPSHOT</version>
-
jenkins为何将testproject- 0.1-20120509.161644-74 .jar上传到Nexus? 20120509.161644-74东西从哪里来?
How come jenkins upload testproject-0.1-20120509.161644-74.jar to Nexus? where is 20120509.161644-74 stuff coming from?
如果时间戳 20120509.161644-74 是jenkins在上传之前生成的,我可以配置它的格式吗?我想要类似testproject-01-$ {timestamp}-$ {reversionId} .jar
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
推荐答案
"Maven部署插件"页面表示默认情况下,当工件的快照版本部署到存储库时,将在其后缀上添加时间戳."因此,它是由插件在调用mvn deploy
时创建的.
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
.
我不知道2)中您想要的是什么.我认为这可能会给Maven带来一些麻烦.
I don't know if what you want in 2) is possible. I think it might cause some trouble for maven.
当您将Maven与SNAPSHOT依赖项一起使用时,时间戳将用于检查SNAPSHOT的最新版本.更改快照的格式可能会导致此机制失败.
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.
这篇关于Jenkins Maven将jar部署到关系-工件命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!