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

Jenkins injects the old git commit as GIT_COMMIT env variable

      Compare GIT_COMMIT, GIT_PREVIOUS_COMMIT with ghprbActualCommit

      GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
      GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
      Setting status of 91cdd0e62caf929448a09caf57df9f99bc7dafd6 to PENDING with url http://jenkins.net:8080/job/build-on-PR/82/ and message: 'Build started sha1 is merged.'
      [EnvInject] - Loading node environment variables.
      Building on master in workspace /var/lib/jenkins/workspace/build-on-PR
      [WS-CLEANUP] Deleting project workspace...
      [WS-CLEANUP] Done
      Cloning the remote Git repository
      Cloning repository git@github.com:example/com.git
      > git init /var/lib/jenkins/workspace/build-on-PR/src/github.com/example/com # timeout=10
      Fetching upstream changes from git@github.com:example/com.git
      > git --version # timeout=10
      using GIT_SSH to set credentials Used for Github integration
      > git -c core.askpass=true fetch --tags --progress git@github.com:example/com.git +refs/heads/:refs/remotes/origin/
      > git config remote.origin.url git@github.com:example/com.git # timeout=10
      > git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10
      > git config remote.origin.url git@github.com:example/com.git # timeout=10
      Fetching upstream changes from git@github.com:example/com.git
      using GIT_SSH to set credentials Used for Github integration
      > git -c core.askpass=true fetch --tags --progress git@github.com:example/com.git +refs/heads/:refs/remotes/origin/ +refs/pull/:refs/remotes/origin/pr/
      > git rev-parse 91cdd0e62caf929448a09caf57df9f99bc7dafd6^

      {commit}

      # timeout=10
      Checking out Revision 91cdd0e62caf929448a09caf57df9f99bc7dafd6 (detached)
      > git config core.sparsecheckout # timeout=10
      > git checkout -f 91cdd0e62caf929448a09caf57df9f99bc7dafd6
      > git rev-list 37b91ca3808f0fe9ae726c1562c1deddd5652ea0 # timeout=10

      [build-on-PR] $ /bin/bash /tmp/hudson4235424762063686423.sh
      + export PROJECTIMPORTPATH=github.com/example/com
      + PROJECTIMPORTPATH=github.com/example/com
      + sort
      + env
      BUILD_CAUSE=GHPRBCAUSE,GHPRBCAUSE
      BUILD_CAUSE_GHPRBCAUSE=true
      BUILD_DISPLAY_NAME=#82
      BUILD_ID=82
      BUILD_NUMBER=82
      BUILD_TAG=jenkins-build-on-PR-82
      BUILD_URL=http://jenkins.net:8080/job/build-on-PR/82/
      EXECUTOR_NUMBER=0
      GIT_AUTHOR_EMAIL=dev+jenkinsbot@example.com
      GIT_AUTHOR_NAME=yoyojenkinsbot
      GIT_BRANCH=item-598
      GIT_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
      GIT_COMMITTER_EMAIL=dev+jenkinsbot@jenkins.example.net.com
      GIT_COMMITTER_NAME=yoyojenkinsbot
      GIT_PREVIOUS_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
      GIT_PREVIOUS_SUCCESSFUL_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
      GIT_URL=git@github.com:example/com.git
      GOROOT=/usr/local/go/1.5.1
      HOME=/var/lib/jenkins
      HUDSON_COOKIE=9bf6d035-21a3-480c-b345-3fc7245e160v
      HUDSON_HOME=/var/lib/jenkins
      HUDSON_SERVER_COOKIE=3fc7dd345e6d2e33
      HUDSON_URL=http://jenkins.net:8080/
      JENKINS_HOME=/var/lib/jenkins
      JENKINS_SCRIPTS=/var/lib/jenkins/workspace/jenkins-scripts/jenkins-scripts
      JENKINS_SERVER_COOKIE=3fc7dd720e6d2e56
      JENKINS_URL=http://jenkins.net:8080/
      JOB_NAME=build-on-PR
      JOB_URL=http://jenkins.net:8080/job/build-on-PR/
      LANG=en_US.UTF-8
      LC_COLLATE=C
      LOGNAME=jenkins
      MAIL=/var/mail/jenkins
      NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
      NODE_LABELS=go master master,
      NODE_NAME=master
      PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/var/lib/jenkins/go/bin
      PDIR=src/github.com/example/com
      PROJECTIMPORTPATH=github.com/example/com
      PROJECTNAME=ms-psps
      PWD=/var/lib/jenkins/workspace/build-on-PR
      ROOT_BUILD_CAUSE=GHPRBCAUSE
      ROOT_BUILD_CAUSE_GHPRBCAUSE=true
      SHELL=/bin/bash
      SHLVL=2
      TERM=xterm-256color
      USER=jenkins
      WORKSPACE=/var/lib/jenkins/workspace/build-on-PR
      XDG_RUNTIME_DIR=/run/user/1000
      XDG_SESSION_ID=23
      XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
      _=/usr/bin/env
      ghprbActualCommit=91cdd0e62caf929448a09caf57df9f99bc7dafd6
      ghprbActualCommitAuthor=Dev1
      ghprbActualCommitAuthorEmail=dev1@example.com
      ghprbAuthorRepoGitUrl=https://github.com/example/com.git
      ghprbCommentBody=test this please
      ghprbCredentialsId=6da1257c-1f41-4b30-ba9e-03af2f772ad1
      ghprbGhRepository=example/com
      ghprbPullAuthorLogin=dev1
      ghprbPullAuthorLoginMention=@dev1
      ghprbPullDescription=GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
      ghprbPullId=21
      ghprbPullLink=https://github.com/example/com/pull/21
      ghprbPullLongDescription=null
      ghprbPullTitle=New backend feature
      ghprbSourceBranch=item-598
      ghprbTargetBranch=master
      ghprbTriggerAuthor=Dev1
      ghprbTriggerAuthorLogin=dev1
      ghprbTriggerAuthorLoginMention=@dev1
      sha1=origin/pr/21/merge

          [JENKINS-31686] Jenkins injects the old git commit as GIT_COMMIT env variable

          Mark Waite added a comment -

          I think that the values are likely due to some interaction between the GitHub Pull Request Builder plugin and the git plugin. What versions of the git plugin, git client plugin, and github pull request builder plugin are you running?

          Mark Waite added a comment - I think that the values are likely due to some interaction between the GitHub Pull Request Builder plugin and the git plugin. What versions of the git plugin, git client plugin, and github pull request builder plugin are you running?

          Kowal Cj0 added a comment -

          I'm running the latest available versions of all of those plugins:

          GIT client plugin=1.19.0
          GIT plugin=2.4.0
          GitHub API Plugin=1.69
          Github Authentication plugin=0.22.2
          GitHub plugin=1.14.0
          GitHub Pull Request Builder=1.29.4

          Kowal Cj0 added a comment - I'm running the latest available versions of all of those plugins: GIT client plugin=1.19.0 GIT plugin=2.4.0 GitHub API Plugin=1.69 Github Authentication plugin=0.22.2 GitHub plugin=1.14.0 GitHub Pull Request Builder=1.29.4

          Kowal Cj0 added a comment -

          What's more surprising is that it's an intermittent issue. I've noticed that sometimes all is fine, an the next build will use wrong commit_id.
          Any ideas what might be wrong?

          Kowal Cj0 added a comment - What's more surprising is that it's an intermittent issue. I've noticed that sometimes all is fine, an the next build will use wrong commit_id. Any ideas what might be wrong?

          +1

          Giuseppe Iannello added a comment - +1

          oeuftete added a comment -

          I see this intermittently as well. Possibility based on results I've seen... maybe this happens only when the old commit supplied to rev-list is not found (because of a forced rebase, say)?

          oeuftete added a comment - I see this intermittently as well. Possibility based on results I've seen... maybe this happens only when the old commit supplied to rev-list is not found (because of a forced rebase, say)?

          William Osler added a comment -

          Interestingly enough, I'm having this same issue, but it's not with the GitHub PR Builder specifically. I'm using a plugin to build PRs from an internal Stash server, and I'm also seeing this behavior. I left a comment on JENKINS-13510 since I think these might actually be the same issue, and that it's a problem with the git plugin itself rather than the pull request builder plugin.

          More details:
          Jenkins: 2.7.5
          Git plugin: 2.5.3
          Refspec:

          +refs/pull-requests/*:refs/remotes/origin/pr/*
          

          Branch Specifier:

          origin/pr/${pullRequestId}/from
          

          Where pullRequestId is the Stash Pull Request number.

          William Osler added a comment - Interestingly enough, I'm having this same issue, but it's not with the GitHub PR Builder specifically. I'm using a plugin to build PRs from an internal Stash server, and I'm also seeing this behavior. I left a comment on JENKINS-13510 since I think these might actually be the same issue, and that it's a problem with the git plugin itself rather than the pull request builder plugin. More details: Jenkins: 2.7.5 Git plugin: 2.5.3 Refspec: +refs/pull-requests/*:refs/remotes/origin/pr/* Branch Specifier: origin/pr/${pullRequestId}/from Where pullRequestId is the Stash Pull Request number.

            Unassigned Unassigned
            kowalcj0 Kowal Cj0
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: