开发者

How to persist variable value in Jenkins

开发者 https://www.devze.com 2023-03-14 09:19 出处:网络
I am a newbie to Jenkins. Basically I want to increment a variable value each time after a job is executed. I created a global variable (Manage Jenkins-->Configure System) with some in开发者_C百科itia

I am a newbie to Jenkins. Basically I want to increment a variable value each time after a job is executed. I created a global variable (Manage Jenkins-->Configure System) with some in开发者_C百科itial value. Now I want this variable value to be incremented each time after my job is executed.

How to go about this? Thanks in advance for any help.


You could keep the current value in a file, and put the file somewhere outside the workspace.

This way you can read it every time you want to, just by checking the file. When you need to update the number, just create a new file, with the value.

Unfortunately, every build creates a new session, so unless you have a global variable defined in the shell itself (outside of Jenkins, like PATH, using (for example) the /etc/profile file) AND have the ability to update it on the fly, it seems very unlikely to work.


Maybe you should consider using $BUILD_NUMBER variable? It is incremented by one for each build.


Use a property value from a file as part of your build and configure a post build action that will check the file with the updated value back into your version control system..

Depending on what number you need you might also want to look at e.g. the maven build number plugin and such things.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号