如何基于一个选定的参数创建一组詹金斯变量? [英] How to create a set of Jenkins variables based on one chosen parameter?
问题描述
我正在使用启用了参数化构建的jenkins自由式项目.
I'm using a jenkins freestyle project which has parameterized build enabled.
如何根据所选参数创建一组变量?
How can I create a set of variables based on the chose parameter?
例如:
当参数
When the parameter param1
is chosen, I want the set of variables to be equal to
CONFIG=config_a.yml
AWS_PROFILE=aws-profile-aa
ANT_BUILD_FILE=buildA
选择param2
时,上述变量集应设置为
When param2
is chosen, the above set of variables should be set to
CONFIG=config_b.yml
AWS_PROFILE=aws-profile-bb
ANT_BUILD_FILE=buildB
CONFIG
,AWS_PROFILE
和ANT_BUILD_FILE
变量将在Execute shell
和Invoke Ant
中访问.
CONFIG
, AWS_PROFILE
, and ANT_BUILD_FILE
variables will be accessed in Execute shell
, and Invoke Ant
.
我不想这样定义3个参数
I don't want to define 3 parameters like this
因为我的jenkins项目永远都不能与CONFIG
= config_a.yml
和AWS_PROFILE
= aws-profile-bb
一起构建.
Because my jenkins project should never build with CONFIG
=config_a.yml
and AWS_PROFILE
=aws-profile-bb
together.
推荐答案
我发现主动选择能够解决我的问题.
I found that Active Choices is able to solve my problem.
此插件可以创建4个这样的参数
This plugin can create 4 parameters like this
一旦test_choice_parameter
更改为param2
,其他3个参数将相应更改.
Once test_choice_parameter
is changed to param2
, the other 3 parameters will change accordingly.
这是我对主动选择"的配置:
Here is my configuration of Active Choices:
这篇关于如何基于一个选定的参数创建一组詹金斯变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!