Need to run a command before git checkout starts through pipeline code. It is similar to using Run buildstep before SCM runs. Thanks in advance
You need to use the options at the beginning to prevent it doing the default checkout first and then trigger the checkout after your initial steps that you wish to do beforehand.
So in your pipeline script declare you agent/tools installations/environment vars then use
options {
skipDefaultCheckout true
}
Then do your pre steps in a stage e.g.
stage('Preparation') {
steps {
//Insert steps here
}
}
Your next stage should then do the checkout that you stopped earlier. This is really simple
stage('Checkout') {
steps {
checkout scm
}
}
Then you can continue your normal steps. Took me a while to find this solution also. I use this to check out another repo first and read it's tag to generate combined version numbers.
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