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

Git Plugin 2.0 has changed contents of GIT_BRANCH

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • Jenkins 1.537; Git Plugin 2.0; Git Client Plugin 1.4.6; SCM API Plugin 0.2

      I've configured a job to clone a repository and use the "develop" branch. With the 1.5 plugin, GIT_PLUGIN was set to "develop". After upgrading to 2.0, GIT_BRANCH is now set to "origin/develop", which breaks my scripts which were relying on the previous value.

          [JENKINS-20446] Git Plugin 2.0 has changed contents of GIT_BRANCH

          David Schmitt created issue -

          Nathan Nutter added a comment -

          I noticed the same problem. I'll be updating my scripts for now. It would be nice to know whether this will be a Won't Fix issue, i.e. a "feature" of 2.0, or whether it might be reverted back to the old behavior.

          Nathan Nutter added a comment - I noticed the same problem. I'll be updating my scripts for now. It would be nice to know whether this will be a Won't Fix issue, i.e. a "feature" of 2.0, or whether it might be reverted back to the old behavior.

          Kevin Burge added a comment -

          I'm guessing this was done to avoid having to add another variable for the repository name?

          Kevin Burge added a comment - I'm guessing this was done to avoid having to add another variable for the repository name?

          Chris Post added a comment -

          +1 Here as well! This change completely broke all of my build scripts the first time around.

          I have since updated everything to accept both possibilities, but changes like this can cause pretty subtle but high-impact problems.

          Chris Post added a comment - +1 Here as well! This change completely broke all of my build scripts the first time around. I have since updated everything to accept both possibilities, but changes like this can cause pretty subtle but high-impact problems.

          Mark Waite added a comment -

          Removed git-client and git-parameter since the definition of the GIT_BRANCH environment variable is in git-plugin

          Mark Waite added a comment - Removed git-client and git-parameter since the definition of the GIT_BRANCH environment variable is in git-plugin
          Mark Waite made changes -
          Component/s Original: git-client [ 17423 ]
          Component/s Original: git-parameter [ 16113 ]
          Labels Original: git git-client New: git

          Mark Waite added a comment -

          The git plugin wiki page documents the current behavior by saying that GIT_BRANCH is the 'name of the remote repository (defaults to origin), followed by name of the branch currently being used, e.g. "origin/master" or "origin/foo"'.

          There are now assertions in GitSCMTest which test that the description in the wiki page is correct, by testing that the GIT_BRANCH environment variable is "origin/master".

          With those two conditions, I'm reasonably confident that the git plugin 2.0 behavior is the expected current behavior and the intended future behavior.

          Mark Waite added a comment - The git plugin wiki page documents the current behavior by saying that GIT_BRANCH is the 'name of the remote repository (defaults to origin), followed by name of the branch currently being used, e.g. "origin/master" or "origin/foo"'. There are now assertions in GitSCMTest which test that the description in the wiki page is correct, by testing that the GIT_BRANCH environment variable is "origin/master". With those two conditions, I'm reasonably confident that the git plugin 2.0 behavior is the expected current behavior and the intended future behavior.
          Mark Waite made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Mark Waite made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

          Tim Pizey added a comment -

          I would like to see this issue reopened and the original change reverted.
          It is not possible to use the current variable with the sonar plugin:

          sonar.branch=$GIT_BRANCH

          breaks as the branch must be a branch, not an append of GIT_REMOTE and GIT_BRANCH.

          The documentation even says that this variable, called GIT_BRANCH, contains the remote and the branch separated by a slash.

          If you need the remote add a new variable called GIT_REMOTE please.

          There are many situations where string manipulation is not available and so expecting me to split on slash is not reasonable and not possible.

          Tim Pizey added a comment - I would like to see this issue reopened and the original change reverted. It is not possible to use the current variable with the sonar plugin: sonar.branch=$GIT_BRANCH breaks as the branch must be a branch, not an append of GIT_REMOTE and GIT_BRANCH. The documentation even says that this variable, called GIT_BRANCH, contains the remote and the branch separated by a slash. If you need the remote add a new variable called GIT_REMOTE please. There are many situations where string manipulation is not available and so expecting me to split on slash is not reasonable and not possible.
          Tim Pizey made changes -
          Resolution Original: Won't Fix [ 2 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]

            Unassigned Unassigned
            davidschmitt David Schmitt
            Votes:
            5 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: