| I had to revert back to a scripted pipeline in order to get throttling to work as intended. The issue seems to be that the throttle option in a Declarative pipeline occurs on a particular agent node, and it's either too late – the executor is already consumed – or it's simply a no-op, but in any case, I'm not seeing any actual evidence of throttling, either overall or per node.
pipeline {
agent { label 'foo' }
options {
throttle(categories: ['MyCategory']) // <-- doesn't do anything, even with MyCategory defined in the system configuration
}
stages {
// ...
}
}
What I would have wanted is either to have the throttle option take effect before the agent is selected, or some sort of declarative syntax that would let me have agent none at the top level of the pipeline (where the throttle option is specified), then the ability to specify a particular agent for all the actual stages to be executed (Build, Test, Publish, etc.). I tried this:
pipeline {
agent none // <-- to avoid having an agent allocated before the throttle category is evaluated
options {
throttle(categories: ['MyCategory'])
}
stages {
stage('Overall') {
agent {
label 'foo' // <-- to get the real agent I want for the real stages
}
stages {
stage('Build') {
// ...
}
stage('Test') {
// ...
}
}
}
}
}
But it simply hung with no useful output. If there's some other way to have agent none at the top level, then a single, reused agent for the actual stages within, I'd be interested to hear about it. I know I could have an agent per stage (Build, Test, etc.), but that wouldn't work for me – it has to be the same machine for all of these, and I'd rather not stash and unstash all the artifacts I need between these stages. |