jenkinsci / jenkinsci/git-plugin

[JENKINS-60591] checkout scm doesn't take revision that started the pipeline

Open
#3,505 2 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

Pipeline job

checkout scm doesn't take revision that started the pipeline instead takes last (fresh) commit from branch 

Related to doc:

https://jenkins.io/doc/book/pipeline/jenkinsfile/


The checkout step will checkout code from source control; scm is a special variable which instructs the checkout step to clone the specific revision which triggered this Pipeline run.

 

To reproduce:



  • Merge to branch (abc)

  • start pipeline

  • pipeline waits for continue (input message)

  • push new change to branch (xyz)

  • resume pipeline

Expect:



  • pipeline resume abc

Observe:



  • pipeline resume xyz

     

Workaround for as - use explicit checkout git commit

variable GIT_COMMIT we defined at the beginning of Pipeline: 

def scmVars = checkout scm

env.GIT_COMMIT = scmVars.GIT_COMMIT

 

And we see that checkout show different results:

 

checkout scm: [$class: 'GitSCM', branches: [[name: "${GIT_COMMIT}"]]]

sh 'cat new_files'
// abc

 

checkout scm

sh 'cat new_files'
// xyz

 

It's a bug or feature? according to the doc - bug... (git plugin?)

 

Can be related with JENKINS-59071 or JENKINS-43761

 

---
Originally reported by mzol, imported from: checkout scm doesn't take revision that started the pipeline


  • status: Open
  • priority: Major
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 2
  • watchers: 4
  • imported: 2025-12-02

Raw content of original issue

Pipeline job

checkout scm doesn't take revision that started the pipeline instead takes last (fresh) commit from branch 

Related to doc:

https://jenkins.io/doc/book/pipeline/jenkinsfile/


The checkout step will checkout code from source control; scm is a special variable which instructs the checkout step to clone the specific revision which triggered this Pipeline run.

 
To reproduce:



  • Merge to branch (abc)

  • start pipeline

  • pipeline waits for continue (input message)

  • push new change to branch (xyz)

  • resume pipeline

Expect:



  • pipeline resume abc

Observe:



  • pipeline resume xyz
     

Workaround for as - use explicit checkout git commit

variable GIT_COMMIT we defined at the beginning of Pipeline: 

def scmVars = checkout scm
env.GIT_COMMIT = scmVars.GIT_COMMIT

 

And we see that checkout show different results:

 



checkout scm: [$class: 'GitSCM', branches: [[name: "${GIT_COMMIT}"]]]

sh 'cat new_files'
// abc


 



checkout scm

sh 'cat new_files'
// xyz


 

It's a bug or feature? according to the doc - bug... (git plugin?)

 

Can be related with JENKINS-59071 or JENKINS-43761

 

  • environment:  Jenkins 2.176.4, git-plugin 3.12.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.