Jenkins键值变量或使用变量定义另一个 [英] Jenkins key-value variable or using a variable to define another

查看:196
本文介绍了Jenkins键值变量或使用变量定义另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个集中的构建系统,其中几个项目被打包".可以使用选择参数选择项目,然后基于该参数构建SVN检出路径.存储库是相同的,但是每个应用程序都有略有不同的路径,例如:

I'm setting up a centralized build system where several projects get "packaged". The project can be selected using a choice parameter, and based on it I'm building the SVN checkout path. The repository is the same, but each app has a slightly different path, eg:

  • app 1驻留在../libs/App1 ..
  • app 2位于../tools/App2 ..

我的问题是我需要以某种方式将应用程序名称与其位置匹配.

My problem is that I need to somehow match the app name with its location.

首先想到的是键值参数,但是我还没有找到允许它的插件.

The first thought that came to mind was a key-value parameter but I have yet to find a plugin that permits it.

第二个是在文件中定义一些环境变量(有2-3个插件可以执行此操作),然后使用在choice参数中选择的值作为环境变量的键.这可以实现吗?

The second one was to define some environmental variables within a file (there are 2-3 plugins that do it) and then use the value selected in the choice parameter to as the key for the env var. Is this achievable in any way?

亲切的问候

推荐答案

几年后:-)并在一个不相关的主题上,我找到了

After a few years :-) and on an unrelated topic, I found the Active choices plugin also known as / forked from uno choice plugin which allows to define parameters which dynamically update when changing other parameters:

1)定义具有以下常规脚本内容的主动选择参数 states

1) define an active choice parameter named states with the following groovy-script content

return[
'Sao Paulo',
'Rio de Janeiro',
'Parana',
'Acre'
]

2)定义一个名为cities主动选择反应参数,该参数对第一个参数值的变化有反应,并具有以下常规脚本内容:

2) Define an active choice reactive parameter named cities which reacts to changes in the first parameter's value, with the following groovy-script content:

if (States.equals("Sao Paulo")) {
  return ["Barretos", "Sao Paulo", "Itu"]
} else if (States.equals("Rio de Janeiro")) {
  return ["Rio de Janeiro", "Mangaratiba"]
} else if (States.equals("Parana")) {
  return ["Curitiba", "Ponta Grossa"]
} else if (States.equals("Acre")) {
  return ["Rio Branco", "Acrelandia"]
} else {
  return ["Unknown state"]
}

因此,每次state更改时,可选的cities列表都会相应更新:

Thus, each time the state changes, then the list of selectable cities will be updated accordingly:

这篇关于Jenkins键值变量或使用变量定义另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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