从另一个触发多分支作业 [英] Trigger Multibranch Job from another
问题描述
我在詹金斯(Jenkins)有一份工作,我需要在工作结束时触发另一个工作(如果工作正确结束).
I have a job in Jenkins and I need to trigger another one when it ends (if it ends right).
第二项工作是多分支,因此我想知道在触发该工作时是否有任何方法可以传递我想要的分支.例如,如果我在开发分支中开始第一个工作,那么我也需要它来触发开发分支中的第二个工作.
The second job is a multibranch, so I want to know if there's any way to, when triggering this job, pass the branch I want to. For example, if I start the first job in the branch develop, I need it to trigger the second one for the develop branch also.
有什么办法可以做到这一点?
Is there any way to achieve this?
推荐答案
仅考虑多分支作业是一个包含以可用分支命名的实际作业的文件夹:
Just think about the multibranch job being a folder containing the real jobs named after the available branches:
在使用管道构建步骤时,您将必须使用类似以下内容的方法:
build(job: 'JOB_NAME/BRANCH_NAME')
.当然,您可以使用变量来指定分支名称.
When using the pipeline build step you'll have to use something like:
build(job: 'JOB_NAME/BRANCH_NAME')
. Of course you may use a variable to specify the branch name.
从Freestyle作业中触发时,您最有可能必须
When triggering from a Freestyle job you most probably have to
- 使用参数化的触发器插件,因为普通的旧的下游构建插件仍然存在触发管道作业的问题(至少是我们正在使用的版本)
- 作业名称使用与上述相同的模式:
JOB_NAME/BRANCH_NAME
应该可以在此处使用job参数指定分支名称.但是,我没有尝试.
Should be possible to use a job parameter to specify the branch name here. However I didn't give it a try, though.
这篇关于从另一个触发多分支作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!