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

checkout scm doesn't take revision that started the pipeline

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    •  Jenkins 2.176.4, git-plugin 3.12.1

      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

       

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

          Mykhailo Zolotarenko created issue -
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Mykhailo Zolotarenko made changes -
          Environment New:  Jenkins 2.176.4, git-plugin 3.12.1
          Mykhailo Zolotarenko made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Mykhailo Zolotarenko made changes -
          Description Original: _{color:#172b4d}checkout scm{color}_ 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:

           
          {code:java}
          checkout scm: [$class: 'GitSCM', branches: [[name: "${GIT_COMMIT}"]]]
          sh 'cat new_files'
          // abc{code}
           
          {code:java}
          checkout scm
          sh 'cat new_files'
          // xyz{code}
           

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

           

          Can be related with JENKINS-59071 or JENKINS-43761

           
          New: +_{color:#172b4d}Pipeline job{color}_+

          _{color:#172b4d}checkout scm{color}_ 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:

           
          {code:java}
          checkout scm: [$class: 'GitSCM', branches: [[name: "${GIT_COMMIT}"]]]
          sh 'cat new_files'
          // abc{code}
           
          {code:java}
          checkout scm
          sh 'cat new_files'
          // xyz{code}
           

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

           

          Can be related with JENKINS-59071 or JENKINS-43761

           

            Unassigned Unassigned
            mzol Mykhailo Zolotarenko
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: