从其他多分支管道触发多分支管道作业 [英] Triggering a multibranch pipeline job from an other multibranch pipeline
问题描述
我有一个场景,但我有 2 个项目(A 和 B),都在 Jenkins 中配置了多分支管道作业,问题是项目 B 依赖于项目 A.
I have a scenario where but I have 2 projects (A and B), both are configured in Jenkins with multibranch pipeline jobs, problem is that Project B depends on Project A.
所以我发现有时候我在项目 A 中签入代码时,我还需要在构建 A 后构建 ProjectB.现在,在我开始调查管道构建之前,我会为每个分支分配一份工作,然后在 Jenkins 中为相应的分支触发项目 B 的相应工作.
So I find that some times when I check in code in Project A, I also need to build ProjectB once A was built. Now before I started investigating pipeline builds, I'd have a job per branch and then trigger in Jenkins the appropriate job for Project B for the appropriate branch.
我想在 Jenkinsfile 中设置什么,以便在 ProjectA/develop 执行时触发 ProjectB 和同一分支的多分支管道作业.
What I'd like to set up in a Jenkinsfile so that when ProjectA/develop executes it then triggers the multibranch pipeline job for ProjectB and the same branch.
我有:
stage ('Trigger Tenant Builds') {
build job: "ProjectB/${branch}", wait: false
}
但我的 ProjectA 管道失败:
But my ProjectA pipeline fails with:
ERROR: No parameterized job named ProjectB/develop found
有什么想法吗?
推荐答案
我现在已经解决了.我正在做的是在项目 B 的 Jenkinsfile 中定义上游触发器:
I've resolved this now. What I am doing is defining an upstream trigger in project B's Jenkinsfile:
pipelineTriggers([
upstream(
threshold: hudson.model.Result.SUCCESS,
upstreamProjects: "/ProjectA/" + env.BRANCH_NAME.replaceAll("/", "%2F")
)
])
这篇关于从其他多分支管道触发多分支管道作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!