I've a pipeline job with following settings
- trigger by post commit of git scm on master branch
- build on master branch
- throttle concurrent builds to have only one build at a time (to have the machine available for other tasks)
The pipeline script:
pipeline {
options {
throttleJobProperty(
categories: ['test_throttle'],
throttleEnabled: true,
throttleOption: 'category',
)
}
agent { label 'MY_MACHINE_LABEL' } {
stage('Preparation') {
steps {
bat "set"
}
}
stage('Work') {
steps {
echo "a lot of work todo"
bat "sleep 1000"
echo "finished"
}
}
}
}
I experienced several pushes on master in a short time, which leads to the build being throttled. When a throttled build is eventually executed, the builds runs on the current master branch, which might not be the commit which has triggered the job.
How can I achieve that the jobs runs on each individual commit on master?
I played around with parsing the bitbucket webhook payload to build exactly the pushed commit, but this seems to be quite complicated.
Is there any way to start executing each build, but only to throttle the time consuming action (which is the stage 'Work' in above example)
Thanks.