-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
-
CentOS 7 + Jenkins 2.53, git-plugin 3.3.0
checkout scm does not detect the latest commit, if the change is made during the same build.
Using git multibranch with "Check out to specific local branch" set to empty(same as **)
Jenkinsfile for testing:
node('somenode'){ deleteDir() checkout scm sh 'cat testfile.txt' sh 'echo "adding new line" >> testfile.txt' sshagent (['your_credentials_id']) { sh('git config --local user.name "Your Name"') sh('git config --local user.email your@email') sh 'git config --local push.default matching' sh("git commit -am 'Add data'") sh('git push') } checkout scm //checkout([$class: 'GitSCM', branches: [[name: '*/your_branch']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'your_credentials_id', url: 'ssh://git@url_to_repo.git']]]) sh 'cat testfile.txt' }
Using "checkout([$class: 'GitSCM', ... " (as shown above) instead of "checkout scm", the correct revision is retrieved and the new values should be shown.
This behaviour is seen on branches with or without slashes (feature/somebranch or somebranch).
This is possibly related with JENKINS-37263, JENKINS-38533 and JENKINS-43468.
Comparing console output between then, there are some differences.
Non existent when using "checkout scm" but is shown on "checkout([$class: 'GitSCM', ... "
Not sure why origin bit is repeated here. "refs/remotes/origin/origin/your_branch^{commit}" but no branch using origin/your_branch exists. Only your_branch.
... git rev-parse refs/remotes/origin/your_branch^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/your_branch^{commit} # timeout=10 ...
refs/remotes/origin/ snippet missing from "checkout scm" but is shown on "checkout([$class: 'GitSCM', ... ".
Checking out Revision your_revision_number (refs/remotes/origin/your_branch)