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

GIT_COMMIT contains unknown value


      When building using the Branch Source plugin setting so that PR's are discovered as merged with master the commit hash put in the env GIT_COMMIT is not a correct value.

      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Checkout SCM)
      [Pipeline] checkout
      Fetching changes from the remote Git repository
      Cleaning workspace
      Fetching without tags
      Merging remotes/origin/master commit 327f14dfdcdf41c01089767ae1ee35409df56d0e into PR head commit b03e30ec40954b8b40ca85374e4cf1d8eb3511cb
      Merge succeeded, producing 7461047c83a98c6ded075bba1bc44f2386d526d6
      Checking out Revision 7461047c83a98c6ded075bba1bc44f2386d526d6 (PR-12)
      {{ > git rev-parse --is-inside-work-tree # timeout=10}}
      {{ > git config remote.origin.url ... # timeout=10}}
      {{ > git rev-parse --verify HEAD # timeout=10}}
      Resetting working tree
      {{ > git reset --hard # timeout=10}}
      {{ > git clean -fdx # timeout=10}}
      Fetching upstream changes from ...
      {{ > git --version # timeout=10}}
      using GIT_SSH to set credentials CI användare i GitHub
      {{ > git fetch --no-tags --progress ... +refs/pull/12/head:refs/remotes/origin/PR-12 +refs/heads/master:refs/remotes/origin/master}}
      {{ > git config core.sparsecheckout # timeout=10}}
      {{ > git checkout -f b03e30ec40954b8b40ca85374e4cf1d8eb3511cb}}
      {{ > git merge 327f14dfdcdf41c01089767ae1ee35409df56d0e # timeout=10}}
      {{ > git rev-parse HEAD^


      # timeout=10}}
      {{ > git config core.sparsecheckout # timeout=10}}
      {{ > git checkout -f 7461047c83a98c6ded075bba1bc44f2386d526d6}}
      Commit message: "Merge commit '327f14dfdcdf41c01089767ae1ee35409df56d0e' into HEAD"
      First time build. Skipping changelog.
      Cleaning workspace


      (later when I print $GIT_COMMIT in an sh step)


      (to provide som debug info I issue some git command in the same sh step
      latest commit seams ok, since its the result of Jenkins merge locally in the workspace)
      08:42:44 + git log -10
      08:42:44 commit 7461047c83a98c6ded075bba1bc44f2386d526d6
      08:42:44 Merge: b03e30e 327f14d
      08:42:44 Author: Jenkins <nobody@nowhere>
      08:42:44 Date: Tue Jan 15 08:42:40 2019 +0100
      {{08:42:44 }}
      08:42:44 Merge commit '327f14dfdcdf41c01089767ae1ee35409df56d0e' into HEAD


      (git show $GIT_COMMIT fails as the hash do not exist)
      08:42:44 + git show 26053fb12db6deb1f9b129b3d6dbeae505cbae39
      08:42:44 fatal: bad object 26053fb12db6deb1f9b129b3d6dbeae505cbae39 


      One maybe related issue is that we are depending on an shared library and I see that there has been changes to the behavior around shared libraries.

      This worked on:

      Git Plugin 3.8.0
      Branch Source Plugin 2.3.3
      Jenkins 2.138.3


            Unassigned Unassigned
            jhoglin Jonas Hoglin
            0 Vote for this issue
            2 Start watching this issue