Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to persist variable value in Jenkins

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.

like image 843
Vaman Kulkarni Avatar asked Jun 22 '11 06:06

Vaman Kulkarni


2 Answers

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.

like image 185
Sagar Avatar answered Oct 20 '22 10:10

Sagar


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

like image 20
Andrey Regentov Avatar answered Oct 20 '22 11:10

Andrey Regentov