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 initial 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With