How do I prevent two pipeline jenkins jobs of the same type to run in parallel on the same node?

sorin picture sorin · Apr 6, 2016 · Viewed 73.8k times · Source

I do not want to allow two jobs of the same type (same repository) to run in parallel on the same node.

How can I do this using groovy inside Jenkinsfile ?

Answer

M0nt3c1t0 picture M0nt3c1t0 · Feb 13, 2018

The answer provided in https://stackoverflow.com/a/43963315/6839445 is deprecated.

The current method to disable concurrent builds is to set options:

options { disableConcurrentBuilds() }

Detailed description is available here: https://jenkins.io/doc/book/pipeline/syntax/#options