Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
OS: Linux 64-bit
Jenkins: 2.190.3
Git plugin: 4.0.0
-
-
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
Issue Links
Activity
Field | Original Value | New Value |
---|---|---|
Assignee | Mark Waite [ markewaite ] |
Remote Link | This issue links to "PR-297 Document limitations of git step (Web Link)" [ 24024 ] |
Summary | Shorthand git step doesn't handle commit hashes | Pipeline git step doesn't handle commit hashes |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Fixed but Unreleased [ 10203 ] |
Summary | Pipeline git step doesn't handle commit hashes | Document that Pipeline git step doesn't handle commit hashes |
Released As | git plugin 4.1.0 | |
Status | Fixed but Unreleased [ 10203 ] | Closed [ 6 ] |