-
Bug
-
Resolution: Fixed
-
Blocker
-
Jenkins 1.650
Git Plugin 2.4.2
When filtering branches with the Multibranch plugin (https://wiki.jenkins-ci.org/display/JENKINS/Multi-Branch+Project+Plugin), user supplied filters in includes/excludes matches more than is expected.
For example, including 'master' matches both 'master' & 'foo/master'.
Attempts to anchor the substring match do not work, as the characters are quoted before being passed to the regex engine.
The following patch addresses the problem by anchoring each element at the start & end:
@@ -318,7 +319,7 @@ public abstract class AbstractGitSCMSource extends SCMSource {
if (wildcard.startsWith("*") || quotedBranches.length()>0)
- quotedBranch.append(Pattern.quote(branch));
+ quotedBranch.append("^" + Pattern.quote(branch) + "$");
}
if (wildcard.endsWith("*")){
quotedBranch.append(".*");