简体   繁体   English

使用Build Pipeline Jenkins插件将参数传递给下游作业

[英]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.

相关问题 如何将下游参数(例如当前构建参数)传递给 Jenkins 的下游作业。 如何为相同的脚本编写管道? - How to Pass downstream parameter ( e.g Current build parameter ) to downstream job of Jenkins. How to write Scripted pipeline for the same? 从詹金斯的自由式作业下游管道作业传递值 - Pass values from a freestyle job downstream pipeline job in jenkins 如何将文件参数传递给 jenkins 管道中的另一个构建作业? - How to pass a file parameter to another build job in jenkins pipeline? 如何在作业中设置 Jenkins Build 参数并传递到下一个管道阶段 - How to set Jenkins Build parameter in a job and pass to next pipeline stage 如何基于詹金斯管道中的参数有条件地运行下游作业? - How to run downstream job conditionally based on a parameter in Jenkins pipeline? 如果新构建在管道中等待,如何强制Jenkins跳过下游作业? - How to force Jenkins to skip a downstream job if a new build is waiting in the pipeline? 我正在使用带有参数的构建管道作业来调用 Jenkins 中的下游作业; 如何在帖子块中打印主要作业名称? - I'm using a build pipeline job with parameters to call a downstream job in Jenkins; how do I print the main job name in the post block? 如何在詹金斯中将参数作为环境变量从上游作业传递到下游作业? 无需对下游工作进行参数化 - How to pass parameter as environment variable from upstream job to downstream job in jenkins? without downstream jobs being parametrized 使用groovy向下游传递构建参数。 詹金斯建立管道 - Passing build parameters downstream using groovy. Jenkins build pipeline Jenkins Pipeline Plugin传递构建在管道中启动的作业之间的作业参数 - Jenkins Pipeline Plugin pass build Job parameters between jobs started in a pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM