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

The Jenkins git-plugin (v 2.3.5) does not handle branch names containing a slash correctly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • git-plugin
    • None
    • Version 2.3.5 of git-plugin

      When a BranchSpec is created by AbstractGitSCMSource it's name doesn't contain the "origin/" prefix. If the branch name doesn't contain a slash ("/"), the branch name is considered "unqualified" and for matching purposes a regular expressing with a "*/" prefix is used.
      If the unqualified branch name contains a slash, it is treated as qualified name and no wildcard is prepended. This has the effect that a branch doesn't match itself (e.g. when polling a repository for changes, see line 591 of GitSCM).

      Given that an unqualified branch name may contain slashes, it is not possible to recognize unqualified branch names from the absence of a slash (see line 124 of BranchSpec).

      A proposed (partial) solution can be found at https://github.com/gv2011/git-plugin/tree/branch-name.

      Here the qualified branch name is used when AbstractGitSCMSource creates a BranchSpec.

      For the String constructor, the problem can possibly be avoided by always using the qualified branch name (prefix "origin/"). Anyway, this is a very confusing situation because SCMHead uses the unqualified name. Additionally, when you talk about a branch in a remote repository, you normally don't care about the local name of the remote repository.

      I suppose that only in very special use cases a name different from "origin" will be needed.

            ndeloof Nicolas De Loof
            gustave Gustave Laville
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: