Jenkins Persistent Editable Global Variable

匆匆过客 提交于 2021-02-10 14:28:56

问题


I'm looking for a plugin/approach that lets me set and read a persistent global variable for use between jobs.

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')}")

Does anyone have any advice about what GolbalSharedThingVal could be?

Many Thanks, Vackar


回答1:


EnvInject plugin is the plugin for anything related to environment variables.

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.

Of course the property file would have to be centrally located on Jenkins master somewhere



来源:https://stackoverflow.com/questions/29674267/jenkins-persistent-editable-global-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!