具有Maven,Jenkins,Nexus的基础架构 [英] Infrastructure with maven, Jenkins, Nexus

查看:125
本文介绍了具有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.

我已经为我们的项目设置了一份有詹金斯的工作. 我将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} .m2 \ settings.xml 添加此部分. 参考文献:

On developers' PCs I copied default maven setting to C:\Users{user}.m2\settings.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>

(我只关注使用Nexus进行存储库管理书籍)

下一步应该做什么? 詹金斯的工作应该有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,您需要包括. Nexus随附了已为快照和发行版设置的特定存储库.您应该为每个路径提供正确的路径,以便maven可以部署快照并将工件释放到正确的存储库.然后,每当您部署工件(通常使用mvn deploy或使用 maven版本插件)时,工件将在那里部署. Nexus默认情况下已启用写身份验证,因此您需要确保添加具有正确的服务器部分将要部署工件的任何人的settings.xml的凭据.詹金斯几乎可以像其他用户一样被对待.如果您使用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天全站免登陆