从属性文件中检索参数 [英] Retrieve parameters from properties file

查看:37
本文介绍了从属性文件中检索参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个使用相同参数和参数值的 Jenkins 参数化作业.当我必须更改其中一个参数的默认值时,我需要检查所有这些作业并重新配置它们.

I have several Jenkins parameterized jobs that uses the same parameters and parameters values. When I have to change the default value of one of those parameters, I need to go over all of those jobs and reconfigure them.

这个问题的一个简单解决方案是从配置文件(在主/工作区中)检索所有参数的选项,但我找不到足够的实现.

A simple solution to this problem would be an option to retrieve all parameters from config file (in the master/ in the workspace) but I could not find a sufficient implementation for that.

我希望能够使用标准 Java 配置文件提供构建 (格式为key"="value") 然后参考这些参数就像构建过程中的所有其他参数一样.

您知道合适的解决方案吗?

Do you know of an appropriate solution?

推荐答案

使用 EnvInject 插件Inject Environment Variables 构建步骤中从文件中读取参数作为环境变量.问题是你不能轻易覆盖它们.一种解决方案是将它与 Conditional BuildStep Plugin 结合使用.然后,您可以定义一个布尔参数 OVERRIDE,默认情况下该参数为 false.只有当 OVERRIDEfalse 时,您才能有条件地运行您的 Inject 构建步骤.当您需要使用手动提供的值覆盖参数时(在自定义调用中运行作业)指定覆盖值并将 OVERRIDE 设置为 true.

Use EnvInject Plugin to read your parameters from a file as environment variables in an Inject Environment Variables build step. The glitch is that then you can't override them easily. One solution would be to use it in conjunction with the Conditional BuildStep Plugin. You can then can define a boolean parameter OVERRIDE that would be false by default. You can then run your Inject build step conditionally only when OVERRIDE is false. When you need to override your parameters with values provided by hand (on in a custom call to run the job) specify the override values and set OVERRIDE to true.

这篇关于从属性文件中检索参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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