So you have to calculate the file on the master? You can't propagate environment variables to slave except when they start. However, you can write a properties file on the master (probably in a well-defined location rather than just "env.properties" as I have said below) and have whatever jobs need the variables download the file from the master and inject files from it. So on the master, you would have:
rm -f env.properties touch env.properties echo "BRANCH = `some_command_that_calculates_branch` >> env.properties echo TIMESTAMP = `date` >> env.properties mv -f env.properties /usr/local/well-known-location/env.properties Doing it this way (rather than writing to /usr/local/well-known-location/env.properties directly) guarantees that /usr/local/well-known-location/env.properties is a complete file at any time. All that being said, this sounds like a weird case to me (probably since I don't have all the info). If you are responding to a checkout by running several jobs on slaves that all need the same environment, the situation becomes a lot easier. Have a job on the master that does the checkout and generates env.properties locally. Then, use the Parameterized Trigger Plugin to have it launch all the other jobs you need, passing in parameters from the file you just wrote. --Rob -----Original Message----- From: jenkinsci-users@googlegroups.com [mailto:jenkinsci-users@googlegroups.com] On Behalf Of John Cary Sent: Wednesday, December 04, 2013 1:43 PM To: jenkinsci-users@googlegroups.com Subject: Re: How to inject environment vars just after the master checkout? Thanks. Questions embedded. On 12/4/2013 10:35 AM, Mandeville, Rob wrote: > We do this all the time. > > After checking out, run a script builder that generates your environment > changes in the form of a properties file. In Unix, you might have lines like: > > rm -f env.properties > touch env.properties > echo "BRANCH = `some_command_that_calculates_branch` >> env.properties > echo TIMESTAMP = `date` >> env.properties > > The "rm" and "touch" is to make sure that the file exists and is > empty. The >> is to append (if you just use '>', you'll clobber all > the lines you wrote earlier) So this would be build step (1), I assume. How do I get this run on the master (and only)? > > Your next build step is to inject environment variables from env.properties. This I understand, I believe. Thanks...John Cary > > --Rob Mandeville > Litle & Co. > > -----Original Message----- > From: jenkinsci-users@googlegroups.com > [mailto:jenkinsci-users@googlegroups.com] On Behalf Of JR Cary > Sent: Wednesday, December 04, 2013 11:59 AM > To: jenkinsci-users@googlegroups.com > Subject: How to inject environment vars just after the master checkout? > > I would like to run a script on master after the SCM checkout, as the script > is in the repo, to set an environment var that propagates to all the slaves. > > It seems that EnvInject cannot do this? > > Or am I missing something? > > Thx.....JC > > FYI, the purpose of this is: I have an svn repo into which I checkout a git > subrepo that I want to update to the same state across all builds. > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > The information in this message is for the intended recipient(s) only and may > be the proprietary and/or confidential property of Litle & Co., LLC, and thus > protected from disclosure. If you are not the intended recipient(s), or an > employee or agent responsible for delivering this message to the intended > recipient, you are hereby notified that any use, dissemination, distribution > or copying of this communication is prohibited. If you have received this > communication in error, please notify Litle & Co. immediately by replying to > this message and then promptly deleting it and your reply permanently from > your computer. > -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.