【发布时间】:2019-07-06 06:33:25
【问题描述】:
我有一个这样的项目结构:
- parent-project : pom.xml
+ child-project: pom.xml
+ child-project-2: pom.xml
我想将子项目的工件上传到 Nexus,所以在我的子项目的 pom.xml 文件中,我定义了:
<distributionManagement>
<repository>
<id>nexus</id>
<url>http://my-repo:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<url>http://my-repo:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
当我在 eclipse 中使用mvn clean deploy 运行子项目时,子项目的 jar 文件会按预期上传到 my-repo nexus 存储库。
在 Jenkins 中,我有一个使用 parent-project pom.xml 配置的工作。现在我想在 jenkins 完成构建过程后将我的子项目的工件发布到 nexus。到目前为止我所做的是:
- 在 Jenkins 中下载并安装了 Nexus 平台插件
- 在 Jenkins 系统配置中使用我的 Nexus 3.x 服务器的凭据配置 Nexus Repository Manager 服务器
- 在 Post-Build 选项卡中,我添加了一个新的 Nexus Repository Manager Publisher,其中包含有关我的 nexus 存储库的信息,但现在卡在 Maven Artifact 会话中,如下所示:
让我感到困惑的是:
- 我应该在 Maven Artifact 会话中添加什么?我试过
child-project/target/child-project-0.0.1-SNAPSHOT.jar,但没有用。 Jenkins 抛出异常
java.io.IOException: child-project/target/child-project-0.0.1-SNAPSHOT.jar 不存在
- 为什么我需要在此处指定工件的版本?是不是说每次修改子项目的版本,都得来这里修改版本?
- 如果我已经在我的子项目的 pom.xml 中定义了与 Info about the Nexus repo 的会话,为什么我需要在这里再次定义它?
- 是否可以像在 Eclipse 中那样直接使用
mvn clean deploy配置作业构建以将工件推送到连接?如果是,那么我不再需要 Nexus Repository Manager Publisher 了吗?以及如何像我在 /.m2 文件夹中的 setting.xml 中那样配置 nexus 服务器的身份验证?
谁能帮我澄清以上几点?非常感谢!
【问题讨论】:
-
只需使用 maven 项目并在 Build 部分添加
mvn clean deploy也可以单击高级选项卡以指定 settings.xml 文件位置。