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?
Asked
Active
Viewed 1.5k times
16

Kara
- 6,115
- 16
- 50
- 57
-
1Check this out: https://github.com/jenkinsci/git-plugin/pull/45. Also more comments here: https://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. – Andrew Cheong Jun 17 '13 at 21:50
-
1@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. – Kara Jun 17 '13 at 22:39
2 Answers
30
Using a negative lookahead worked for me:
^(?!.*master).*$
Should trigger on everything except master. Kudos to this questions answers.

Community
- 1
- 1

romanofski
- 1,122
- 1
- 12
- 18
-
4If entering this in the branches specifier in Jenkins, don't forget to prepend `:` to tell Jenkins this is a regex. – Rylander Jun 08 '16 at 18:21
2
The following worked for me:
^(master.+|(?!master).*)$
This excludes master only. Not master_joda, for example.
It is also based on these answers.

Aleksey Kasatkin
- 21
- 1