Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins parameterized downstream build trigger plugin - only on certain branch?

I have the following scenario: Build A is building multiple branches (CI build for github repository), and I want it to trigger Build B, but only if the branch == "master".

I found that I can enable downstream triggers under "Post Build Actions" > "Trigger parameterized build on other projects". I picked the downstream project and to only build when stable. So far, so good.

Then, I found that I can do "Restrict matrix execution to a subset" and I put this in:

"${BRANCH}"=="master"

However, it still builds the downstream project B regardless of whether the branch is master, or something completely different (it then btw. builds the downstream project with the same branch as project A).

Am I misunderstanding something here? Isn't this the way to filter the downstream execution?

If it's not at all, is there any other way to only build the downstream project when the branch is "master"?

Here's the parameterized trigger plugin btw.

like image 526
mac Avatar asked Oct 31 '22 10:10

mac


1 Answers

Actually found a solution that seems to work just fine based on the discussion in this pull request

The solution is to use the flexible publish plugin and come up with the conditions for the build. Then, under actions, pick the parameterized trigger plugin to kick off the other build.

For the conditions you can use the "current build status" to only trigger on successful builds, and then I used string matcher to make sure the branch equals "master". I think the boolean condition option would have worked too.

According to the thread, whatever I wanted to do directly in the parameterized trigger plugin with the execution matrix restrictions won't work.

like image 184
mac Avatar answered Nov 15 '22 06:11

mac