6
votes

I am using Jenkins (v1.592) with Git Client Plugin (v1.12.0) and Git Plugin (v2.3).

I have a build-job that has to be triggered if there have been changes in my git-repository if the changes are made NOT in origin/master or origin/name branches, while N is a decimal number.

I was very happy to see, that Jenkins allowes regular expressions as a branch-specifier at the "Branches to build" option. But unfortunately I do not get my expression to work correctly:

My expression is:

:master|name(\d+)

I also activated "Strategy for choosing what to build" with option "Inverse".

When I am now pushing something onto my master-build it will be selected and the build starts.

I am using "Poll SCM" with no schedule and trigger a build with a call to the Jenkins notifyCommit URL.

I also tried to use: (?!(origin/master|origin/name\d+)) as regex without inverse option but get an error here.

1
If this is a regex question, what regex engine are you using? Typically, nobody writes their own engine, they use a standard one. They will say its something compatible. Otherwise, its a new series of non-standard constructs.user557597
@vks Unfortunately that did not solve the problem.Stefan Wegener
@sln As Jenkins is written in Java, I assume, that it uses the Java regex-engine.Stefan Wegener

1 Answers

6
votes

Okay, I found an answer, but not by finding a solution for the regex. I recently saw, that I am able to specify more than one branch with the "Add Branch" function - until few minutes ago I was blind to see the "Add Branch" button.

By specifiying two branches and activating the inverse function it works. My two branch names are: master and name* (* for the Wildcard operator).

Thanks for your help!