如何基于一个选定的参数创建一组詹金斯变量? [英] How to create a set of Jenkins variables based on one chosen parameter?

查看:130
本文介绍了如何基于一个选定的参数创建一组詹金斯变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用启用了参数化构建的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

CONFIGAWS_PROFILEANT_BUILD_FILE变量将在Execute shellInvoke 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.ymlAWS_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屋!

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