[英]Pass parameter to downstream job using Build Pipeline Jenkins plugin
Under my pipeline there are 3 jobs. 在我的管道下有3个工作。 1st job has one parameter. 第一个作业有一个参数。 while Executing pipeline- its prompted me to pass paramters. 在执行管道时-提示我通过参数。 My third job also has parameters to pass...but its not asking me to pass parameters. 我的第三项工作也有参数要传递...但是它没有要求我传递参数。
So My pipeline is not getting executed throughly. 因此,我的管道无法完全执行。
Take all the parameters needed int he first job and than pass it to subsequent jobs. 在第一个工作中获取所有需要的参数,然后将其传递给后续工作。
For example --> Job A requires "Param_A", Job B requires "Param_B" and Job C requires "Param_C", than the parent job should take all the three Param in it's input and call the subsequent job with those parameters, and later which ever parameter is required by the job would be utilised by $PARAM_A 例如->作业A需要“ Param_A”,作业B需要“ Param_B”,而作业C需要“ Param_C”,那么父作业应在其输入中获取所有三个Param并使用这些参数调用后续作业,然后再调用$ PARAM_A将使用作业需要的参数
You can use Parameterized Build Plugin to accomplish that. 您可以使用Parameterized Build Plugin完成此操作。
For example you want your 1st job to trigger the 2nd job (eg. called TEST) and pass a parameter to it. 例如,您希望您的第一个作业触发第二个作业 (例如称为TEST)并将参数传递给它。 What you need to do is on the 1st job on Post-build Actions
section choose Trigger parameterized build on other projects
and set it up like the image below: 您需要做的是在“ Post-build Actions
部分的第一项工作上,选择“ Trigger parameterized build on other projects
然后进行设置,如下图所示:
On the 2nd job on the General
section tick the box This project is parameterized
and define the name of the parameter you are passing form the 1st job. 在“ General
部分的第二个作业上,勾选“ This project is parameterized
”框,并定义您要从第一个作业传递的参数的名称。
For example: 例如:
To pass this parameter(or any other parameter) to the 3rd job you need to apply the same approach. 要将此参数(或任何其他参数)传递给第三工作,您需要应用相同的方法。
In short: 简而言之:
On 2nd job go to Post-build Actions
section choose Trigger parameterized build on other projects
and fill the name of the 3rd job in the field Project to build
. 在第二个作业上,转到Post-build Actions
部分,选择“ Trigger parameterized build on other projects
然后在Project to build
字段中填写第三个作业的名称。 In the field Predefined parameters add again PARAMETER_NAME=${PARAMETER_NAME}
在“预定义参数”字段中,再次添加PARAMETER_NAME=${PARAMETER_NAME}
On 3rd job tick the box This project is parameterized
and define the name of the parameter you are passing form the 2nd job (eg. PARAMETER_NAME
), for this case as a String Parameter. 在第3个作业上,勾选This project is parameterized
的框,并定义您要从第2个作业传递的参数的名称(例如PARAMETER_NAME
),在这种情况下为字符串形参。
Note 注意
You can follow the same logic to pass the parameter(s) to as many downstream jobs you want. 您可以遵循相同的逻辑将参数传递给所需的许多下游作业。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.