小编典典

Jenkins Maven将jar部署到关系-工件命名

jenkins

我的java / maven项目“ testproject”与我的jenkins和nexus回购挂钩:

我的pom.xml看起来像:

....    
<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>
......

在我的詹金斯设置中,我有:

Build - maven3 - clean deploy

正如预期的那样,jenkins将工件上传到Nexus。查看jenkins build的控制台输出,如下所示:

[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中指定的版本是

<version>0.1-SNAPSHOT</version>
  1. jenkins为何将testproject- 0.1-20120509.161644-74 .jar 上传到Nexus?20120509.161644-74产品从哪里来?

  2. 如果时间戳 20120509.161644-74 是jenkins在上传之前生成的,我可以配置它的格式吗?我想要类似testproject-01-$ {timestamp}-$ {reversionId} .jar的文件


阅读 260

收藏
2020-07-25

共1个答案

小编典典

行家部署插件页面告诉“默认情况下,当一个工件的快照版本部署到仓库,时间戳作为后缀为”。因此,它是由插件在您调用时创建的mvn deploy

我不知道您想要的2)是否可行。我认为这可能会给行家带来麻烦。

当您将Maven与SNAPSHOT依赖项一起使用时,时间戳用于检查SNAPSHOT的最新版本。更改快照的格式可能会导致此机制失败。

2020-07-25