Jenkins - How Can I Pass Parameters from Upstream to Downstream

I have 3 assemblies: A is the Master assembly that controls the flow of the B-Anoter build C- will be executed after B I want to add the String parameter to A so that the user manually enters the String string, and I'm not sure how I can pass this parameter in B. let's say this is my assembly thread:

assembly ("B") build ("C") I do not know how I can specify the parameter in B, should I do this from the assembly thread or from the assembly configuration of B, and how can I do this.

Thanks in advance Alex

+6
source share
5 answers

Something like that:

build("B", B_parameter: params["A_parameter"])<br> build("C") 

https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin

+3
source

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 run another task 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 parameterized assemblies (i.e., request a value for the parameter). This option is next to the top of the job configuration page. For example, to take a parameter, you call MY_ID . Now it is available as $ MY_ID in assembly A.

Now, when you create A an, it requests MY_ID. Then add the build step to Job A to start โ€œBโ€ with the parameters and pass all the parameters of assembly A to it. Now in assembly B there will also be the parameter $ MY_ID that was set when you started assembly A.

+2
source

A parameterized trigger plugin is what you are looking for. For more information on how to pass a parameter from the main assembly to the child assembly, check my answer in this link.

+2
source

Wooooow, so after a couple of hours of the game โ€œWhich plugin is missing in 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 redirected, go to this other stack overflow answer , which details the problems. If you feel too lazy and just want to check that the SECURITY-170 problem is the main problem, you can try this temporary solution, as it does not persist after a reboot:

  • Manage Jenkins โ†’ Manage Nodes โ†’ Choose your โ€œWizard,โ€ no matter what he calls
  • Select Script Console
  • Paste this and click Run : System.setProperty("hudson.model.ParametersAction.keepUndefinedParameters", "true")
  • Retry the assembly that did not redirect the parameters.

If this worked for you, you can check this answer . I put together another question, but I would advise you to read both the question and the context of my answer before trying to do this.

+1
source

Here are the scripts of my pipeline (Master Build A) for passing 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 customize
- mainpath and mainrevision as parameters of the pipeline parameters,
- srcpath and revision as parameters of child tasks

0
source

Source: https://habr.com/ru/post/973821/


All Articles