Jenkins 选择参数不同的显示

Csa*_*agó 6 pom.xml maven jenkins

我想为 Jenkins 作业添加一个选择参数。该列表是固定的,但我希望 Dropbox 显示自定义值,而不是实际值(类似于网页名称而不是其 URL)。

在某些情况下,这是pom.xml文件的路径,但是,我想显示模块名称而不是完整路径。一个例子:

Actual value                         | What I want to be displayed
-------------------------------------|----------------------------
full/path/to/my/modules/pom.xml      | All modules
full/path/to/my/modules/util/pom.xml | Utilities
full/path/to/my/modules/data/pom.xml | Data handling
Run Code Online (Sandbox Code Playgroud)

我在这里先向您的帮助表示感谢!

A21*_*21z 6

使用Active Choices插件,您可以使用 groovy 地图进行设置:

使用以下 groovy 脚本设置“Active Choices Parameter”:

return['full/path/to/my/modules/pom.xml' : 'All modules',
'full/path/to/my/modules/util/pom.xml' : 'Utilities',
'full/path/to/my/modules/data/pom.xml' : 'Data handling']
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

地图的“值”将显示在构建参数选择中: 在此输入图像描述

地图的“key”将被设置在变量中:

> echo "$URL"
full/path/to/my/modules/pom.xml
Run Code Online (Sandbox Code Playgroud)


use*_*692 4

您可以使用扩展选择参数插件来完成此操作。

要按照您想要的方式设置它,请在“此构建已参数化”下,选择扩展选择参数,然后进行如下设置:

在此输入图像描述

请注意,根据您使用的 Jenkins 版本,它可能看起来有点不同,但应该不会有太大不同(此屏幕截图是在 2.0-beta-2 上)。