I have the following advanced scripted pipeline in a Jenkinsfile:
stage('Generate') {
node {
checkout scm
}
parallel windows: {
node('windows') {
sh 'cmake . -Bbuild.windows -A x64'
}
},
macos: {
node('apple') {
sh '/usr/local/bin/cmake . -DPLATFORM="macos" -Bbuild.macos -GXcode'
}
},
ios: {
node('apple') {
sh '/usr/local/bin/cmake . -DPLATFORM="ios" -Bbuild.ios -GXcode'
}
}
}
Note the top node
that precedes the parallel windows/macos/ios nodes. Does this mean that checkout scm
will be invoked on every subsequent building node (windows/apple), before proceeding to the parallel steps? In other words, does the script above guarantee that the repository will be checked out on every node that will be involved at any stage of this build?
Many thanks.
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.
In Jenkins, SCM stands for "Source Code Management". This option instructs Jenkins to obtain your Pipeline from Source Control Management (SCM), which will be your locally cloned Git repository.
In a pipeline scm checkout, when using non-lightweight checkout, and the global setting "SCM checkout retry count" is a non-zero value, if a build is performing the initial scm clone and the build is cancelled, the retry will relaunch the scm step as per the retry count.
The first node
step will allocate any build agent and check out the source code.
Later, additional nodes will be allocated, where I can promise you that cmake
will fail, as it works with an empty directory.
You can use stash
and unstash
to copy over the files that are needed for the build (and subsequent stages):
stage('Generate') {
node {
checkout scm
stash 'source'
}
parallel windows: {
node('windows') {
unstash 'source'
sh 'cmake . -Bbuild.windows -A x64'
}
},
macos: {
node('apple') {
unstash 'source'
sh '/usr/local/bin/cmake . -DPLATFORM="macos" -Bbuild.macos -GXcode'
}
},
ios: {
node('apple') {
unstash 'source'
sh '/usr/local/bin/cmake . -DPLATFORM="ios" -Bbuild.ios -GXcode'
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With