Is there a way to access updated system environment variable from Jenkins?

19 views
Skip to first unread message

rabie....@gmail.com

unread,
Jun 22, 2017, 8:18:38 AM6/22/17
to Jenkins Users

I have an analysis number variable in my batch script that increments after every job build. I have to get this new value in my post build email notification. Jenkins job makes a copy of all system environment variables at the start up and this way I keep getting the same environment variable value in my post-build email, even though my analysis number environment variable stored in the system has incremented. 


My question is there a way to access the system environment variable and not its copy stored in Jenkins?

Baptiste Mathus

unread,
Jun 22, 2017, 9:50:38 AM6/22/17
to jenkins...@googlegroups.com
Hello, IIUC your question then it's not really a Jenkins issue.
Spawned processes from Jenkins will inherit the values from environment from when it started.

IMO you should/could consider changing that design to retrieve this counter from somewhere Central (think a registry like zookeeper or consul, or even a dbms table possibly).

In any case using this environment var principle is going to prove complex, and even more when using Jenkins agents (where env is not the master's).

My 2 cents

Le 22 juin 2017 2:18 PM, <rabie....@gmail.com> a écrit :

I have an analysis number variable in my batch script that increments after every job build. I have to get this new value in my post build email notification. Jenkins job makes a copy of all system environment variables at the start up and this way I keep getting the same environment variable value in my post-build email, even though my analysis number environment variable stored in the system has incremented. 


My question is there a way to access the system environment variable and not its copy stored in Jenkins?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0b01a537-7f38-44b3-b23f-15dbcde97130%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

t3knoid

unread,
Jun 22, 2017, 10:27:50 AM6/22/17
to Jenkins Users
I don't think there is a way. Are you using a source control system? You can store the variable value/pair into a property file. You can then commit it into your source as a post-build process. Otherwise, you can just store it in a property file located in the build server.
Reply all
Reply to author
Forward
0 new messages