Jenkins持久性可编辑全局变量 [英] Jenkins Persistent Editable Global Variable
问题描述
我正在寻找一种插件/方法,可以让我设置和读取持久性全局变量以供作业之间使用.
I'm looking for a plugin/approach that lets me set and read a persistent global variable for use between jobs.
这种情况是,我有CI作业,可以在代码库的各个分支上运行测试,并且我想关联一个与发布分支的最后一个稳定版本相对应的内部版本号.即
The scenario is that I have CI job that runs tests on various branches of the codebase and I want to associate a build number that corresponds to the last stable build of the release branch. i.e.
Build No Branch Result GolbalSharedThingVal
5 release Success 1.5
6 dev Fail 1.5
7 dev Success 1.7
8 release Unstable 1.7
9 release Success 1.9
10 release Fail 1.9
然后在我的部署工作中,我想使用一个常规的构建后操作来用该版本对构建进行注释:
Then in my deployment job I want to annotate the build with the version using a groovy post build action:
manager.addShortText(" ${manager.build.env.get('GolbalSharedThingVal')}")
有人对GolbalSharedThingVal可能是什么有任何建议吗?
Does anyone have any advice about what GolbalSharedThingVal could be?
非常感谢, 瓦卡
推荐答案
EnvInject 插件是与环境变量相关的任何东西的插件.
不知道设置持久性全局变量(这与Jenkins的设计原理相违背),但是您可以让作业将值导出到属性文件,而其他作业在初始化时从属性文件读取值并将其作为环境变量公开给其他构建步骤.
Don't know about setting a persistent global variable (that goes against the design principles of Jenkins), but you could have the job export a value to a properties file, and other jobs read the value from the properties file at initialization and expose it as environment variable to other build steps.
当然,该属性文件必须位于Jenkins主文件的中央位置
Of course the property file would have to be centrally located on Jenkins master somewhere
这篇关于Jenkins持久性可编辑全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!