Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45140

Add support of throttling of the entire build in Declarative Pipeline

      So, I'm having this problem that I described in a similar bug for the lockable-resource plugin (JENKINS-45138). I said to myself, "oh, hey, I remember being able to throttle executions on a per-agent basis!"

      Imagine my surprise when I hit the documentation and find that throttle is only applicable inside a step.

      I need to acquire, use, and cleanup exclusive access to a resource on each agent. Will throttle work how I expect?

      step('foo') {
          throttle(['foo-label'])
          bat '... acquire the resource...'
          bat '... use the resource...'
      }
      post {
          always {
              bat '... cleanup the resource...'
          }
      }
      

          [JENKINS-45140] Add support of throttling of the entire build in Declarative Pipeline

          Anthony Mastrean created issue -
          Anthony Mastrean made changes -
          Summary Original: How do I throttle an entire declarative pipeline job? New: How do I throttle an entire declarative pipeline job per-agent?

          Oleg Nenashev added a comment - - edited

          Likely the Throttle Job property will work, or not... If no, it is a feature request, not a defect. declarative Pipeline is a simplified syntax by design, and such use-cases need to be added there by Declarative plugin maintainers. CC abayer

           

          Oleg Nenashev added a comment - - edited Likely the Throttle Job property will work, or not... If no, it is a feature request, not a defect. declarative Pipeline is a simplified syntax by design, and such use-cases need to be added there by Declarative plugin maintainers. CC abayer  
          Oleg Nenashev made changes -
          Issue Type Original: Bug [ 1 ] New: New Feature [ 2 ]
          Oleg Nenashev made changes -
          Summary Original: How do I throttle an entire declarative pipeline job per-agent? New: Add support of throttling of the entire build in Declarative Pipeline
          Oleg Nenashev made changes -
          Component/s New: pipeline-model-definition-plugin [ 21706 ]
          Oleg Nenashev made changes -
          Assignee Original: Oleg Nenashev [ oleg_nenashev ]

          Andrew Bayer added a comment -

          Yeah, just do something like

          pipeline {
            agent {
              label "whatever"
            }
            options {
              throttle(['some-category'])
            }
            ...
          

          And it should work. =)

          Andrew Bayer added a comment - Yeah, just do something like pipeline { agent { label "whatever" } options { throttle([ 'some-category' ]) } ... And it should work. =)
          Andrew Bayer made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          I'm going to try this immediately! Is this commonly supported by plugins that provide pipeline steps? Or did you have to specifically code support for this scope? I'm looking at the Throttle and Lock Resource plugins to try to solve the same problem and neither mention that you can use them in the options block.

          Maybe we can get a documentation update?

          Anthony Mastrean added a comment - I'm going to try this immediately! Is this commonly supported by plugins that provide pipeline steps? Or did you have to specifically code support for this scope? I'm looking at the Throttle and Lock Resource plugins to try to solve the same problem and neither mention that you can use them in the options block. Maybe we can get a documentation update?

            Unassigned Unassigned
            anthonymastrean Anthony Mastrean
            Votes:
            32 Vote for this issue
            Watchers:
            41 Start watching this issue

              Created:
              Updated: