Does 'scm checkout' always give the same result with parallel builds in JenkinsFiles ?

601 views
Skip to first unread message

sleipnir

unread,
Sep 21, 2016, 11:38:29 PM9/21/16
to Jenkins Users
Hi

I was playing with JenkinsFiles and Organization folders (multi-branch pipeline) and I was wondering:
Is there is any guarantee the 'checkout scm' command would checkout the exact same revision on all node, even if new commits are pushed before the build is finished ?
Also, I saw an environment variable that gives the branch name (BRANCH_NAME) but nothing for the revision.
Do I have to call a git command after the 'checkout scm' command to extract the sha1 so I can stamp the build output properly ? (something like 'git rev-parse HEAD')

Here's a test jenkinsfile I'm using:

stage 'build'

parallel (
  BuildDebug: { node {
    checkout scm

 
 }},
  BuildRelease: { node {
    checkout scm
 
 }}
)

Thanks

Mark Waite

unread,
Sep 21, 2016, 11:53:06 PM9/21/16
to Jenkins Users
The intent of the checkout scm step is that it takes a single revision, and uses that revision for the duration of the job.

Unfortunately, a bug was found during discussions after Jenkins World which seem to indicate that there area cases where git plugin 2.5.3 and beyond risks not checking out the same revision for every use of "checkout scm" within a single job.



Those fixes have not yet been included in a plugin release.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4fb3bb94-a954-4e2e-aecf-5786432aa08b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sleipnir

unread,
Sep 22, 2016, 12:20:37 AM9/22/16
to Jenkins Users

Thanks for the quick reply.
Any info about the recommended way to get the sha that was actually used ?

guy.i...@klarna.com

unread,
Mar 19, 2017, 4:07:26 AM3/19/17
to Jenkins Users
Was this merged already?
Is it safe to use checkout scm within for parallel jobs?

Mark Waite

unread,
Mar 19, 2017, 6:47:05 AM3/19/17
to Jenkins Users
It was released as part of git plugin versions git-3.1.0,  git-3.0.5, git-3.0.4, git-3.0.3, git-3.0.2, git-3.0.1, git-2.6.5, git-2.6.4, git-2.6.2, and  git-2.6.1.

Mark Waite

Reply all
Reply to author
Forward
0 new messages