Jenkins选择参数与不同的显示

时间:2016-09-09 08:11:46

标签: maven jenkins pom.xml

我想在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

提前感谢您的帮助!

3 个答案:

答案 0 :(得分:1)

您可以使用Extended Choice Parameter plugin

执行此操作

要按照您想要的方式进行设置,请在“此构建已参数化”下,选择扩展选择参数,并将其设置为:

enter image description here

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

答案 1 :(得分:1)

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

使用以下常规脚本设置“主动选择参数”:

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']

enter image description here

地图的“值”将显示在构建参数选项中: enter image description here

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

> echo "$URL"
full/path/to/my/modules/pom.xml

答案 2 :(得分:0)

多年以来,一直没有一个简单的解决方案来解决这个问题,就像用choice插件编写display | value行一样,我感到很痛苦,所以我终于编写了自己的插件:https://github.com/Avalancs/ChoiceWithDisplay 您可以从发布标签中获取.hpi文件,如果您不知道如何安装.hpi文件,请查看以下SO帖子:https://stackoverflow.com/a/19588907/7216760