问题描述
我有一个场景,但是我有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.
因此,我发现有些时候在Project A中签入代码时,一旦A构建完成,我还需要构建ProjectB.现在,在开始调查管道构建之前,我每个分支都有一份工作,然后在Jenkins中为适当的分支为Project 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")
)
])
这篇关于从另一个多分支管道触发多分支管道作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!