• Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins 2.8
      Git plugin 2.5.2
      Git client plugin 1.19.6

      The environment variables documented here https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeaturesorigin%2Fmaster are always NULL

      Example script

      node (){
          echo "${env.PATH}";
          git branch: 'develop', credentialsId: 'xxxxx', url: 'git@xxx.com:org/repo.git'
          echo "${env.GIT_BRANCH}";
          echo "${env.GIT_URL}";
          echo "${env.JAVA_HOME}";
          echo "${env.NODE_NAME}";
          echo "${env.JOB_NAME}";
      }
      

      Produces this output in the console

      Started by user xxxx
      [Pipeline] node
      Running on xxxx in /home/jenkagent01/jenkinsroot/workspace/pipeline-example
      [Pipeline] {
      [Pipeline] echo
      /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
      [Pipeline] git
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url xxxxx # timeout=10
      Fetching upstream changes from xxxx
       > git --version # timeout=10
      using GIT_SSH to set credentials 
       > git -c core.askpass=true fetch --tags --progress git@xxxx +refs/heads/*:refs/remotes/origin/*
       > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
      Checking out Revision b4d38494c725ccbdc1d66a68a31eb65eb23b3dae (refs/remotes/origin/develop)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
       > git branch -a -v --no-abbrev # timeout=10
       > git branch -D develop # timeout=10
       > git checkout -b develop b4d38494c725ccbdc1d66a68a31eb65eb23b3dae
       > git rev-list b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
      [Pipeline] echo
      null
      [Pipeline] echo
      null
      [Pipeline] echo
      null
      [Pipeline] echo
      xxxxx
      [Pipeline] echo
      pipeline-example
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      Searching only leads me to this which seems like a hack -> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/gitcommit/gitcommit.groovy

      For example http://stackoverflow.com/questions/35554983/git-variables-in-jenkins-workflow-plugin

          [JENKINS-36436] Environment variables are always NULL

          Haddad Said created issue -
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Mark Waite made changes -
          Link New: This issue duplicates JENKINS-35230 [ JENKINS-35230 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 173143 ] New: JNJira + In-Review [ 184961 ]
          Cyrille Le Clerc made changes -
          Description Original: The environment variables documented here https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeaturesorigin%2Fmaster are always NULL

          Example script
          {{
          node (){
              echo "${env.PATH}";
              git branch: 'develop', credentialsId: 'xxxxx', url: 'git@xxx.com:org/repo.git'
              echo "${env.GIT_BRANCH}";
              echo "${env.GIT_URL}";
              echo "${env.JAVA_HOME}";
              echo "${env.NODE_NAME}";
              echo "${env.JOB_NAME}";
          }}}

          Produces this output in the console



          Started by user xxxx
          [Pipeline] node
          Running on xxxx in /home/jenkagent01/jenkinsroot/workspace/pipeline-example
          [Pipeline] {
          [Pipeline] echo
          /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
          [Pipeline] git
           > git rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url xxxxx # timeout=10
          Fetching upstream changes from xxxx
           > git --version # timeout=10
          using GIT_SSH to set credentials
           > git -c core.askpass=true fetch --tags --progress git@xxxx +refs/heads/*:refs/remotes/origin/*
           > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
          Checking out Revision b4d38494c725ccbdc1d66a68a31eb65eb23b3dae (refs/remotes/origin/develop)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
           > git branch -a -v --no-abbrev # timeout=10
           > git branch -D develop # timeout=10
           > git checkout -b develop b4d38494c725ccbdc1d66a68a31eb65eb23b3dae
           > git rev-list b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
          [Pipeline] echo
          null
          [Pipeline] echo
          null
          [Pipeline] echo
          null
          [Pipeline] echo
          xxxxx
          [Pipeline] echo
          pipeline-example
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS

          Searching only leads me to this which seems like a hack -> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/gitcommit/gitcommit.groovy

          For example http://stackoverflow.com/questions/35554983/git-variables-in-jenkins-workflow-plugin

          New: The environment variables documented here https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeaturesorigin%2Fmaster are always NULL

          Example script
          {code}
          node (){
              echo "${env.PATH}";
              git branch: 'develop', credentialsId: 'xxxxx', url: 'git@xxx.com:org/repo.git'
              echo "${env.GIT_BRANCH}";
              echo "${env.GIT_URL}";
              echo "${env.JAVA_HOME}";
              echo "${env.NODE_NAME}";
              echo "${env.JOB_NAME}";
          }
          {code}

          Produces this output in the console


          {noformat}
          Started by user xxxx
          [Pipeline] node
          Running on xxxx in /home/jenkagent01/jenkinsroot/workspace/pipeline-example
          [Pipeline] {
          [Pipeline] echo
          /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
          [Pipeline] git
           > git rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url xxxxx # timeout=10
          Fetching upstream changes from xxxx
           > git --version # timeout=10
          using GIT_SSH to set credentials
           > git -c core.askpass=true fetch --tags --progress git@xxxx +refs/heads/*:refs/remotes/origin/*
           > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
           > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
          Checking out Revision b4d38494c725ccbdc1d66a68a31eb65eb23b3dae (refs/remotes/origin/develop)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
           > git branch -a -v --no-abbrev # timeout=10
           > git branch -D develop # timeout=10
           > git checkout -b develop b4d38494c725ccbdc1d66a68a31eb65eb23b3dae
           > git rev-list b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
          [Pipeline] echo
          null
          [Pipeline] echo
          null
          [Pipeline] echo
          null
          [Pipeline] echo
          xxxxx
          [Pipeline] echo
          pipeline-example
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {noformat}

          Searching only leads me to this which seems like a hack -> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/gitcommit/gitcommit.groovy

          For example http://stackoverflow.com/questions/35554983/git-variables-in-jenkins-workflow-plugin

          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-26100 [ JENKINS-26100 ]
          Jesse Glick made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          CloudBees Inc. made changes -
          Remote Link New: This issue links to "CloudBees Internal OSS-1639 (Web Link)" [ 18617 ]
          Mark Waite made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            Unassigned Unassigned
            haddad Haddad Said
            Votes:
            11 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: