Nexus 工件上传 [英] Nexus Artifacts Uploading

查看:30
本文介绍了Nexus 工件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 jenkins shell 将工件上传到 nexus 并自动生成版本?我正在使用这个脚本,我想在工件上传时自动生成版本.

How to upload artifacts to nexus with auto generating the version by using jenkins shell? I am using this script and I want to generate the version automatically when artifact uploading.

 mvn deploy:deploy-file 
          -DgroupId= 
          -DartifactId= 
          -Dversion=  
          -DgeneratePom= 
          -Dpackaging= 
          -DrepositoryId= 
          -Durl= 
          -Dfile= 

推荐答案

您可以在 Jenkins 管道中使用 ${env.BUILD_NUMBER} 变量来指定工件版本.

You can use ${env.BUILD_NUMBER} variable in your Jenkins pipeline to specify the artifact version.

要做到这一点,有几个选项:

To do this there are few options:

  1. 如果您想在 mvn deploy 期间将工件发布到 Nexus,那么您可以使用 pom.xml 文件中的 ${revision} 参数.为此,您需要将此变量放入 <version> 标记中.例如,<version>1.0-${revision}</version>然后将其提供给 Jenkins 管道中的 maven 命令:mvn deploy -Drevision=${env.BUILD_NUMBER}.有关详细信息,请参阅答案.
  2. 您还可以使用 Nexus Jenkins 插件 将工件上传到 nexus 并使用 ${env.BUILD_NUMBER} 变量指定工件版本.有关详细信息,请参阅.
  1. If you want to publish artifacts to Nexus during mvn deploy, then you can use ${revision} parameter in pom.xml file. To do this, you need to put this variable into <version> tag. E.g., <version>1.0-${revision}</version> and then provide it to the maven command in Jenkins pipeline: mvn deploy -Drevision=${env.BUILD_NUMBER}. See this answer for details.
  2. Also you can use Nexus Jenkins Plugin to upload artifacts to nexus and specify the artifact version using ${env.BUILD_NUMBER} variable. See this for details.

这篇关于Nexus 工件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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