Jenkins Gerrit trigger on all branches except master
Asked Answered
E

2

16

I have a build in Jenkins triggered by Gerrit I would like to trigger on all branches except master. What regex should I use for this?

Elise answered 17/6, 2013 at 19:26 Comment(2)
Check this out: github.com/jenkinsci/git-plugin/pull/45. Also more comments here: issues.jenkins-ci.org/browse/JENKINS-7087. I don't understand enough to translate these comments into a solution, but if you could, it'd be great if you could type up an answer yourself for future users.Archenteron
@acheong87 Unfortunately the solution you found only works if you are using the git plugin directly, I have the Choosing Strategy set to Gerrit Trigger so it will not work for me.Elise
A
30

Using a negative lookahead worked for me:

^(?!.*master).*$

Should trigger on everything except master. Kudos to this questions answers.

Akiko answered 10/9, 2013 at 0:36 Comment(1)
If entering this in the branches specifier in Jenkins, don't forget to prepend : to tell Jenkins this is a regex.Tonne
S
3

The following worked for me:

^(master.+|(?!master).*)$

This excludes master only. Not master_joda, for example.

It is also based on these answers.

Spinet answered 27/3, 2018 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.