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

后端 未结 10 1979
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 02:18

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 ?

10条回答
  •  甜味超标
    2020-12-01 03:18

    I think there are more than just one approach to this problem.

    Pipeline

    • Use latest version of Lockable Resources Plugin and its lock step, as suggested in other answer.
    • If building the same project:
      • Uncheck Execute concurrent builds if necessary.
    • If building different projects:
      • Set different node or label for each project.

    Jenkins

    • Limit number of node's executors to 1?

    Plug-ins

    • Build Blocker Plugin - supposedly supports Pipeline projects
    • Throttle Concurrent Builds Plugin - not compatible with Pipeline projects

提交回复
热议问题