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

Git plugin sets wrong branch name GIT_BRANCH (more than 2 branches with same SHA1)

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Production

      Git plugin ver: 2.4.4

      In jenkins job we configure Git plugin ->
      Branches to build/Branch specifier: origin/ready/**

      Developer pushes code to central git repository, which Jenkins check into 2 branches:
      git push origin bugfix:sergey/bugfix
      git push origin bugfix:ready/bugfix

      When Jenkins job kicks in, it provides this output:

      14:01:36 > git branch -a -v --no-abbrev --contains 24ef859065480d5ac965652cfce8a0dd959fd082 # timeout=10
      14:01:36 Checking out Revision 24ef859065480d5ac965652cfce8a0dd959fd082 (origin/sergey/bugfix, origin/ready/bugfix)
      ..
      ..

      14:01:36 HOME=/var/lib/jenkins
      14:01:36 GIT_BRANCH=origin/sergey/bugfix
      14:01:36 EXECUTOR_NUMBER=1

      As you can see GIT_BRANCH got set to "origin/sergey/bugfix"
      and this is wrong because we asked for branch to match origin/ready/**

      This causes problems in our build process

          [JENKINS-33984] Git plugin sets wrong branch name GIT_BRANCH (more than 2 branches with same SHA1)

          Sergey Leonovich created issue -
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]

          Mark Waite added a comment -

          You might try using the local branch extension that was added in git plugin 2.4.4. It may be able to checkout the branch which matches the name from the branch spec, rather than reporting the name of the first branch mentioned in the rev-parse output.

          Mark Waite added a comment - You might try using the local branch extension that was added in git plugin 2.4.4. It may be able to checkout the branch which matches the name from the branch spec, rather than reporting the name of the first branch mentioned in the rev-parse output.
          Sergey Leonovich made changes -
          Attachment New: screenshot-1.png [ 32376 ]
          Sergey Leonovich made changes -
          Attachment New: screenshot-2.png [ 32377 ]

          Sergey Leonovich added a comment - - edited

          I cannot seem to find "local branch extension that was added in git plugin 2.4.4" you mentioning

          Sergey Leonovich added a comment - - edited I cannot seem to find "local branch extension that was added in git plugin 2.4.4" you mentioning
          Sergey Leonovich made changes -
          Attachment Original: screenshot-2.png [ 32377 ]
          Sergey Leonovich made changes -
          Attachment Original: screenshot-1.png [ 32376 ]
          Sergey Leonovich made changes -
          Attachment New: screenshot-1.png [ 32378 ]

            Unassigned Unassigned
            sleonovich Sergey Leonovich
            Votes:
            14 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated: