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

Document that Pipeline git step doesn't handle commit hashes

    XMLWordPrintable

Details

    • git plugin 4.1.0

    Description

      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.

       

       

      Attachments

        Activity

          jmacloue Jeff MacLoue created issue -
          markewaite Mark Waite made changes -
          Field Original Value New Value
          Assignee Mark Waite [ markewaite ]
          markewaite Mark Waite made changes -
          Remote Link This issue links to "PR-297 Document limitations of git step (Web Link)" [ 24024 ]
          markewaite Mark Waite made changes -
          Summary Shorthand git step doesn't handle commit hashes Pipeline git step doesn't handle commit hashes
          markewaite Mark Waite made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Fixed but Unreleased [ 10203 ]
          markewaite Mark Waite made changes -
          Summary Pipeline git step doesn't handle commit hashes Document that Pipeline git step doesn't handle commit hashes
          markewaite Mark Waite made changes -
          Released As git plugin 4.1.0
          Status Fixed but Unreleased [ 10203 ] Closed [ 6 ]

          People

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

            Dates

              Created:
              Updated:
              Resolved: