0

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.

amw
  • 452
  • 1
  • 5
  • 14
  • If a Jenkins job is a queue and the subsequent SCM trigger without any change in the parameter- Jenkins will pretend nothing changes, Hence it will not queue the other job. You have to somehow to cheat Jenkins by adding some random value in the parameter like [Random String Parameter](https://plugins.jenkins.io/random-string-parameter/) – Samit Kumar Patel Feb 06 '21 at 21:11
  • Thanks @SamitKumarPatel That helps me to understand why I only see one build in the queue. Furthermore I found this [comment](https://stackoverflow.com/a/36487614/3526758) and why using lock step is the better approach than to use the throttle plugin. – amw Feb 08 '21 at 06:17

0 Answers0