Jenkins构建使用Nexus工件(所有GAV)的版本进行参数化 [英] Jenkins build parameterized with a choice of versions of a Nexus artifact (all GAVs)

查看:313
本文介绍了Jenkins构建使用Nexus工件(所有GAV)的版本进行参数化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个Jenkins插件可以对我的Nexus回购进行组工件版本(GAV)搜索并列出结果?我希望将结果作为选择(下拉列表)在参数化构建中可用.

Is there a Jenkins plugin that can do a group-artifact-version (GAV) search of my Nexus repo and list the results? I would like the results to be available on a parameterized build as a choice (a dropdown).

推荐答案

无需自定义Ruby脚本.现在有一个专用插件可以满足您的需求: Maven元数据Jenkins CI服务器插件

No need for custom Ruby scripts. There is now a dedicated plugin which does what you require: Maven Metadata Plugin for Jenkins CI server

只需标记列出Maven工件版本"类型的参数化内部版本"和添加参数"即可:

Just mark "Parameterized Build" and "Add Parameter" of type "List Maven artifact versions":

  • 名称MY_SNAPSHOT_JAR
  • 存储库基本URL(这很棘手)http://localhost/nexus/service/local/repositories/snapshots/content
  • Name MY_SNAPSHOT_JAR
  • Repository Base URL (this one is tricky) http://localhost/nexus/service/local/repositories/snapshots/content

然后将一个shell命令添加到wget/scp/etc,您可以使用以下由插件解析的变量:

Then add a shell command to wget/scp/etc, you can use the following variables resolved by plugin:

wget "$MY_SNAPSHOT_JAR_ARTIFACT_URL"
echo    "$MY_SNAPSHOT_JAR_VERSION" - the version you selected in the dropdown or that was selected as part of an automated build
echo    "$MY_SNAPSHOT_JAR_ARTIFACT_URL" - the full URL to the actual artifact selected. You can use something like "wget" to download that artifact and do something with it.
echo    "$MY_SNAPSHOT_JAR_GROUP_ID" - echoes back your configuration
echo    "$MY_SNAPSHOT_JAR_ARTIFACT_ID" - echoes back your configuration
echo    "$MY_SNAPSHOT_JAR_CLASSIFIER" - echoes back your configuration
echo    "$MY_SNAPSHOT_JAR_PACKAGING" - echoes back your configuration

不幸的是,您无法在同一下拉列表中询问快照和释放.可能的解决方法是为MY_RELEASE_JAR添加另一个参数(因此,还有另一个下拉列表,这会使用户感到困惑).另一个解决方法是为发布部署安排一个单独的工作.

Unfortunately you cannot ask about snapshot and release in the same dropdown list. A possible workaround is to add another parameter for MY_RELEASE_JAR (thus another dropdown list, somewhat confusing for a user). Another workaround is to have a separate job for release deployment.

这篇关于Jenkins构建使用Nexus工件(所有GAV)的版本进行参数化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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