I have 3 builds:
A - is the Master build which control the flow
B- Anoter build
C- will be executed after B
I want to add a String parameter to A so the user will enter some String manually, and i'm not sure how can i path this parameter to B.
lets say that this is my build flow:
build("B")
build("C")
I don't know how can i path the parameter to B, should i do that from the build flow or from the B build configuration and how can i do that.
Thanks in advance
Alex
Something like this:
build("B", B_parameter: params["A_parameter"])<br>
build("C")
https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin
One way to do this is with the Parameterized Trigger plugin: https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
This allows you to trigger another job using, but not limited to:
* a set of predefined properties
* properties from a properties file read from the workspace of the triggering build
* the parameters of the current build
With Build A, B, and C you set th3m up as a parameterized builds (i.e. to ask for a value for a parameter). This a setting near the start of the job config page. For example to take a parameter you name MY_ID
. This is now accessible as $MY_ID in build A.
Now, when you build A an it prompts for MY_ID. Then add a build step in Job A to trigger "B" with parameters, and pass it all the parameters of build A. Now build B will also have the parameter $MY_ID that was set when you ran a build of A.
Parameterized Trigger Plugin is what you're looking for. For details on how to pass parameter from master build to child build, check my answer in this link.
Wooooow, so after a couple hours of playing "Which plugin is missing from this equation?", it turned out that none of these answers worked due to a jenkins change called SECURITY-170.
If you followed the steps in this answer and your parameters are not being forwarded, please go to this other Stack Overflow answer which provides the details of the issue. If you're feeling too lazy and just want to verify that SECURITY-170 is the crux of the issue, you can try this temporary solution, as it does not persist after reboot:
- Manage Jenkins -> Manage Nodes -> Select your "Master", whatever it's named
- Select the Script Console
- Paste this in and hit the
Run
button: System.setProperty("hudson.model.ParametersAction.keepUndefinedParameters", "true")
- Retry the build that wasn't forwarding parameters
If that worked for you, you can check this answer I assembled on another question, but I would advise you read both the question and the context of my answer before attempting it.
Here is my pipeline (Master Build A) scripts to pass parameters to child jobs (Child Build B)
build job: 'svn test', parameters: [string(name: 'srcpath', value: params["mainpath"]), string(name: 'revision', value: params["mainrevision"])]
I configure
-- mainpath and mainrevision as pipeline jobs parameters,
-- srcpath and revision as child jobs parameters