Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-33441

GitSCMSource: Includes & excludes match more than expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • git-plugin
    • 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(".*"); }
      • quotedBranch.append(Pattern.quote(branch));
        + quotedBranch.append("^" + Pattern.quote(branch) + "$");
        }
        if (wildcard.endsWith("*")){
        quotedBranch.append(".*");

            Unassigned Unassigned
            evildeece Alastair D'Silva
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: