|
I want to assign to a parameter and pass that parameter to another
job. So I say in Job 1, "This build is parameterized" and define a string parameter "hasChanged" with default value, false. Halfway thorugh Job 1, I have a Windows batch command which does set %hasChanged%=true echo this 1st cmd window says hasChanged = %hasChanged% But in a subsequent Windows batch command I do echo this 2nd cmd windows says hasChanged = %hasChanged% At the end of Job 1, I "Trigger/call builds on other projects" with the "Current build parameters". The problem is the variable is not preserved after the first batch command. What is the solution? |
|
I think I'm basically asking how best to pass information (eg:
variables) between jobs. Can you even assign to environment variables in Jenkins? On Aug 16, 7:41 pm, shanz <[hidden email]> wrote: > I want to assign to a parameter and pass that parameter to another > job. > So I say in Job 1, "This build is parameterized" and define a string > parameter "hasChanged" with default value, false. > > Halfway thorugh Job 1, I have a Windows batch command which does > set %hasChanged%=true > echo this 1st cmd window says hasChanged = %hasChanged% > > But in a subsequent Windows batch command I do > echo this 2nd cmd windows says hasChanged = %hasChanged% > > At the end of Job 1, I "Trigger/call builds on other projects" with > the "Current build parameters". > > The problem is the variable is not preserved after the first batch > command. > > What is the solution? |
|
Hi,
The plugin https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin is probably the right solution for you. regards didier On Aug 16, 8:58 pm, shanz <[hidden email]> wrote: > I think I'm basically asking how best to pass information (eg: > variables) between jobs. > Can you even assign to environment variables in Jenkins? > > On Aug 16, 7:41 pm, shanz <[hidden email]> wrote: > > > I want to assign to a parameter and pass that parameter to another > > job. > > So I say in Job 1, "This build is parameterized" and define a string > > parameter "hasChanged" with default value, false. > > > Halfway thorugh Job 1, I have a Windows batch command which does > > set %hasChanged%=true > > echo this 1st cmd window says hasChanged = %hasChanged% > > > But in a subsequent Windows batch command I do > > echo this 2nd cmd windows says hasChanged = %hasChanged% > > > At the end of Job 1, I "Trigger/call builds on other projects" with > > the "Current build parameters". > > > The problem is the variable is not preserved after the first batch > > command. > > > What is the solution? > > |
|
In reply to this post by shanz
On 16.08.2011 20:58, shanz wrote:
> I think I'm basically asking how best to pass information (eg: > variables) between jobs. > Can you even assign to environment variables in Jenkins? > You cannot. And this has little to do with Jenkins. A child process (the shell, ant, etc.) cannot change the environment of the parent process (the Jenkins Job process). However, as Didier points out in his reply, you can use the [https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin] because it allows for "properties from a properties file read from the workspace of the triggering build". So you'll need to put the (changed) parameters you want to pass on into a file and then use this to fill in the parameters of the downstream Job. cheers, Martin > On Aug 16, 7:41 pm, shanz<[hidden email]> wrote: >> I want to assign to a parameter and pass that parameter to another >> job. >> So I say in Job 1, "This build is parameterized" and define a string >> parameter "hasChanged" with default value, false. >> >> Halfway thorugh Job 1, I have a Windows batch command which does >> set %hasChanged%=true >> echo this 1st cmd window says hasChanged = %hasChanged% >> >> But in a subsequent Windows batch command I do >> echo this 2nd cmd windows says hasChanged = %hasChanged% >> >> At the end of Job 1, I "Trigger/call builds on other projects" with >> the "Current build parameters". >> >> The problem is the variable is not preserved after the first batch >> command. >> >> What is the solution? |
|
Martin,
I see. I had come to the same conclusion and have managed to create a workaround. Since my parameter it a boolean, I create a file in a shared custom workspace and the second job tests for the existence of the file. On Aug 17, 7:19 am, "Martin B." <[hidden email]> wrote: > On 16.08.2011 20:58, shanz wrote: > > > I think I'm basically asking how best to pass information (eg: > > variables) between jobs. > > Can you even assign to environment variables in Jenkins? > > You cannot. And this has little to do with Jenkins. > A child process (the shell, ant, etc.) cannot change the environment of > the parent process (the Jenkins Job process). > > However, as Didier points out in his reply, you can use the > [https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin] > because it allows for "properties from a properties file read from the > workspace of the triggering build". So you'll need to put the (changed) > parameters you want to pass on into a file and then use this to fill in > the parameters of the downstream Job. > > cheers, > Martin > > > > > > > > > On Aug 16, 7:41 pm, shanz<[hidden email]> wrote: > >> I want to assign to a parameter and pass that parameter to another > >> job. > >> So I say in Job 1, "This build is parameterized" and define a string > >> parameter "hasChanged" with default value, false. > > >> Halfway thorugh Job 1, I have a Windows batch command which does > >> set %hasChanged%=true > >> echo this 1st cmd window says hasChanged = %hasChanged% > > >> But in a subsequent Windows batch command I do > >> echo this 2nd cmd windows says hasChanged = %hasChanged% > > >> At the end of Job 1, I "Trigger/call builds on other projects" with > >> the "Current build parameters". > > >> The problem is the variable is not preserved after the first batch > >> command. > > >> What is the solution? |
| Powered by Nabble | Edit this page |
