使用 maven、Jenkins、Nexus 的基础设施 [英] Infrastructure with maven, Jenkins, Nexus

查看:35
本文介绍了使用 maven、Jenkins、Nexus 的基础设施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 Maven.我想设置基础设施,以便自动构建的工件将转到 Nexus 存储库.然后它们可以被开发人员使用.

We are using maven. I want to set up infrastructure, so that automatically built artifacts would go to Nexus repository. And then they could be used by developers.

我已经为我们的项目设置了 Jenkins 的 1 个工作.我将 Nexus 设置在同一台服务器上.

I have already set up Jenkins with 1 job for our project. And I set up Nexus to on the same server.

在开发人员的 PC 上,我将默认的 Maven 设置复制到 C:Users{user}.m2settings.xml添加此部分.参考资料:

On developers' PCs I copied default maven setting to C:Users{user}.m2settings.xml adding this section. References:

配置 Maven 以使用单个 Nexus

Maven 设置参考

<mirror>
  <!--This sends everything else to /public -->
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://myserver:8081/nexus/content/groups/public</url>
</mirror>

(我只关注 Repository Management with Nexus 书)

我的下一步应该是什么?Jenkins 工作应该有 mvn install 吗?如何为公司工件创建 Nexus 存储库?

What are my next steps should be? Should Jenkins job have mvn install? How to create Nexus repository for company artifacts?

推荐答案

要将工件部署到 Nexus,您需要包含一个 distributionManagement 部分 在你的 pom 中.Nexus 附带已为快照和版本设置的特定存储库.您应该为每个路径提供正确的路径,以便 maven 将快照部署并将工件发布到正确的存储库.然后任何时候部署工件——通常使用 mvn deploy 或使用 maven 发布插件,工件将部署在那里.默认情况下,Nexus 具有写入身份验证,因此您需要确保添加具有正确的 服务器部分将部署工件的任何人的 settings.xml 凭据.Jenkins 可以像任何其他用户一样被对待.如果您让它在构建时执行 deploy,那么每个构建都将部署到 Nexus.还有一个用于部署工件的构建后操作,以防您希望它稍后在 Jenkins 作业中发生.

To deploy artifacts to Nexus, you'll need to include a distributionManagement section in your pom. Nexus ships with specific repositories already set up for both snapshots and releases. You should give the correct path to each of those so that maven will deploy snapshot and release artifacts to the correct repos. Then any time you deploy artifacts--typically with mvn deploy or using the maven release plugin, the artifacts will be deployed there. Nexus has write authentication on by default, so you'll need to make sure to add a server section with the correct credentials to the settings.xml of anyone who will be deploying artifacts. Jenkins can be treated pretty much like any other user. If you have it do a deploy as its build, then every build will deploy to Nexus. There's also a post-build action for deploying artifacts in case you want it to happen later in the Jenkins job.

这篇关于使用 maven、Jenkins、Nexus 的基础设施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆