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

GIT_BRANCH Variable Now Contains the Remote Name

      Previously, the Bitbucket Server integration plugin set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable set to example-branch. After upgrading to 4.0.0 of the plugins, that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

       

      Example code

       stage("Print GIT_BRANCH"){
           steps{
             echo env.GIT_BRANCH
         }
       } 

      Output on 3.6.0

      aidaleuc/smoketests

      Output on 4.0.0

      origin/aidaleuc/smoketests

          [JENKINS-73502] GIT_BRANCH Variable Now Contains the Remote Name

          Aidan created issue -
          Aidan made changes -
          Summary Original: GIT_BRANCH Variable Now Contains the Remote New: GIT_BRANCH Variable Now Contains the Remote Name
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Case #1: Test Pod Build"){
              steps{
                sh "echo ${GIT_BRANCH}"
                sh "echo ${env.GIT_BRANCH}"
             }
           } {code}
           

           

          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Case #1: Test Pod Build"){
              steps{
                sh "echo ${GIT_BRANCH}"
                sh "echo ${env.GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Case #1: Test Pod Build"){
              steps{
                sh "echo ${GIT_BRANCH}"
                sh "echo ${env.GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                sh "echo ${GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                sh "echo ${GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                sh "echo ${GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                sh "echo ${GIT_BRANCH}"
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo env.GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin use to set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo env.GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo env.GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          Aidan made changes -
          Description Original: Previously, the Bitbucket Server integration plugin set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable would be set to example-branch. After upgrading to 4.0.0 of the plugins that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo env.GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests
          New: Previously, the Bitbucket Server integration plugin set the GIT_BRANCH environment variable equal to the local branch name checked out by Jenkins. In versions of the plugin < 3.6.0 a multibranch pipeline's job named example/example-branch would have a GIT_BRANCH variable set to example-branch. After upgrading to 4.0.0 of the plugins, that same variable would be origin/example-branch. This is breaking a lot of our Jenkinsfiles that depend on the previous behavior.

           

          Example code
          {code:java}
           stage("Print GIT_BRANCH"){
              steps{
                echo env.GIT_BRANCH
             }
           } {code}
          Output on 3.6.0

          aidaleuc/smoketests

          Output on 4.0.0

          origin/aidaleuc/smoketests

          Hi Aidan, thanks for the report. We've confirmed it, this is a case of us breaking API without realising as part of the 4.0 release and is a valid issue.

          We need to investigate this further so we can provide better instruction on how to move forward but so far I think we agree this change was unintentional and the "origin/" should be stripped from the response in a future bugfix release- this will be confirmed on the ticket when it is picked up.

          Thanks,

          Martin

          Martin Henschke added a comment - Hi Aidan, thanks for the report. We've confirmed it, this is a case of us breaking API without realising as part of the 4.0 release and is a valid issue. We need to investigate this further so we can provide better instruction on how to move forward but so far I think we agree this change was unintentional and the "origin/" should be stripped from the response in a future bugfix release- this will be confirmed on the ticket when it is picked up. Thanks, Martin

            Unassigned Unassigned
            aidaleuc Aidan
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: