Jenkins 键值变量或使用一个变量定义另一个变量
我正在建立一个集中式构建系统,其中几个项目被“打包”。可以使用选择参数来选择项目,并基于它我正在构建 SVN 签出路径。存储库是相同的,但每个应用程序的路径略有不同,例如:
- 应用程序 1 驻留在 ../libs/App1..
- 应用程序 2 驻留在 ../tools/App2..
- 等
我的问题是我需要以某种方式将应用程序名称与其位置相匹配。
我首先想到的是键值参数,但我还没有找到允许它的插件。
第二个是在文件中定义一些环境变量(有 2-3 个插件可以做到这一点),然后使用在 choice 参数中选择的值作为环境变量的键。这可以通过任何方式实现吗?
亲切的问候
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 resides in ../libs/App1..
- app 2 resides in ../tools/App2..
- etc
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.
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?
Kind regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 条件 BuildStep 插件 与 EnvInject 插件 以设置环境变量(例如
APP_PATH
)取决于任何其他构建步骤之前的构建参数。然后,当您在构建中需要时,您可以使用${APP_PATH}
。You can use Conditional BuildStep Plugin together with EnvInject Plugin in order to set up an environment variable (say
APP_PATH
) that depends on your build parameters before any other build steps. You then use${APP_PATH}
whenever you need it in your build.几年后:-)在一个不相关的主题上,我发现了 主动选择插件也称为/派生自uno choice插件允许定义在更改其他参数时动态更新的参数:
1)定义一个名为
states
的主动选择参数以下 groovy-script 内容2) 定义一个名为
cities
的主动选择反应参数,它对第一个参数值的变化做出反应,使用以下 groovy -脚本内容:因此,每次
州
发生变化,则可选择的城市
列表将相应更新: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) define an active choice parameter named
states
with the following groovy-script content2) Define an active choice reactive parameter named
cities
which reacts to changes in the first parameter's value, with the following groovy-script content:Thus, each time the
state
changes, then the list of selectablecities
will be updated accordingly: