詹金斯选择参数有不同的显示
Jenkins choice parameter with different display
我想为 Jenkins 作业添加一个选择参数。该列表是固定的,但我希望保管箱显示自定义值,而不是实际值(类似于网页名称而不是其 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
提前感谢您的帮助!
您可以使用 Extended Choice Parameter plugin 来做到这一点。
如需设置,请在"This build is parameterized"下选择扩展选择参数,并按如下方式设置:
请注意,根据您使用的 Jenkins 版本不同,它可能看起来有些不同,但应该不会有太大差异(此屏幕截图是在 2.0-beta-2 上)。
苦恼这个问题这么多年都没有简单的解决办法,比如用choice插件写一个display|value行,所以我终于写了自己的插件:https://github.com/Avalancs/ChoiceWithDisplay
您可以从发布选项卡获取 .hpi 文件,如果您不知道如何安装 .hpi 文件,请检查此 SO post:
借助 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']
地图的"value"将显示在构建参数选项中:
而地图的"key"会被设置在变量中:
> echo "$URL"
full/path/to/my/modules/pom.xml
我想为 Jenkins 作业添加一个选择参数。该列表是固定的,但我希望保管箱显示自定义值,而不是实际值(类似于网页名称而不是其 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
提前感谢您的帮助!
您可以使用 Extended Choice Parameter plugin 来做到这一点。
如需设置,请在"This build is parameterized"下选择扩展选择参数,并按如下方式设置:
请注意,根据您使用的 Jenkins 版本不同,它可能看起来有些不同,但应该不会有太大差异(此屏幕截图是在 2.0-beta-2 上)。
苦恼这个问题这么多年都没有简单的解决办法,比如用choice插件写一个display|value行,所以我终于写了自己的插件:https://github.com/Avalancs/ChoiceWithDisplay 您可以从发布选项卡获取 .hpi 文件,如果您不知道如何安装 .hpi 文件,请检查此 SO post:
借助 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']
地图的"value"将显示在构建参数选项中:
而地图的"key"会被设置在变量中:
> echo "$URL"
full/path/to/my/modules/pom.xml