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

Document that Pipeline git step doesn't handle commit hashes



    • Bug
    • Resolution: Fixed
    • Minor
    • git-plugin
    • OS: Linux 64-bit
      Jenkins: 2.190.3
      Git plugin: 4.0.0
    • git plugin 4.1.0


      Despite git step description states that "this step is shorthand for the generic SCM step", it behaves differently when specifying commit hash as a branch to checkout. Consider the following pipeline:


      repo = 'https://github.com/jmacloue/mypwgen-pl.git'
      branch = 'ad0f6e4'
      pipeline {
          agent any
          stages {
              stage("GitSCM") {
                  steps {
                      checkout([$class: 'GitSCM',
                                userRemoteConfigs: [[url: repo]],
                                branches: [[name: branch]],
              stage("shorthand") {
                  steps {
                      git url: repo, branch: branch

      Though the stages should be identical according to docs, the second stage fails:

       > git fetch --tags --force --progress -- https://github.com/jmacloue/mypwgen-pl.git +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git rev-parse ad0f6e4^{commit} # timeout=10
      Checking out Revision ad0f6e453986b1a068d1d6cab4aef37f254ab86e (detached)
       > git rev-parse refs/remotes/origin/ad0f6e4^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/ad0f6e4^{commit} # timeout=10
       > git rev-parse origin/ad0f6e4^{commit} # timeout=10
      ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
      Finished: FAILURE

      However if branch is set to "master" - it works just fine.


       > git rev-parse origin/master^{commit} # timeout=10
      Checking out Revision ad0f6e453986b1a068d1d6cab4aef37f254ab86e (origin/master)
       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
      Checking out Revision ad0f6e453986b1a068d1d6cab4aef37f254ab86e (refs/remotes/origin/master)

      So, it looks like git step follows a completely different path from what the checkout step does. Either git step's description or, preferably, its behaviour needs to be changed.


      PS I vaguely recall that at some point the stages worked identical indeed but now it's definitely not so.






            Unassigned Unassigned
            jmacloue Jeff MacLoue
            0 Vote for this issue
            2 Start watching this issue