Jenkins Pipeline throttle other jobs

Viewed 1885

I'm trying to lock some other jobs from runing when a jenkins pipeline is running,
I've been trying to use the exclusion-plugin or the throttle-concurrent-builds-plugin
with this kind of structure :

 node(){
     stage "test"
     allocate('test')
     sleep time: 15, unit: 'MINUTES'
     sh "echo 'yes'" }

@NonCPS
def allocate(String resource){

  throttle = new hudson.plugins.throttleconcurrents.ThrottleJobProperty(
    maxConcurrentPerNode=1,
    maxConcurrentTotal=1,
    categories = [resource],
    throttleEnabled=true,
    throttleOption="category",
    matrixOptions=null
    )
  throttle.setOwner()
  throttle = null
  return true
}

But it doesn't seems to do anything...
I'm starting with the Groovy Pipeline plugin, and I'm block by the inability to throttle other jobs
Thank You for your help !

2 Answers
Related