How can I prevent two Jenkins projects/builds from running concurrently?

前端 未结 3 1681
猫巷女王i
猫巷女王i 2020-12-14 15:18

I have two Jenkins projects that share a database. They must not be run simultaneously. Strictly speaking, there is no particular dependency between them beyond non concurre

3条回答
  •  心在旅途
    2020-12-14 16:21

    EDIT: Below information is effective as of 04/10/2014

    Exclusion plugin, https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin Very useful if few build use the same resource - e.g. a test database. All you need to do is to update configuration of all jobs using this resource and as a result they will never run in parallel but wait for others to complete.

    Taken from : http://www.kaczanowscy.pl/tomek/2012-07/jenkins-plugins-part-iii-towards-continuous-delivery

    This plugin does block two or more jobs from running in parallel.
    To test, do this for job1

    1. Configure
    2. Under Build Environment check "Add resource to manage exclusion."
    3. Then Add -> New Resource -> Name -> lock
    4. Under Build -> Add build step
    5. Critical Block Start
    6. Add build step -> Add whatever you want to add.(add sleep 15 to make sure it lasts longer to check concurrency.)
    7. Add build step -> Critical block end
    8. Repeat the above steps for job2, make sure you use the same lock name 'lock'.
    9. manually build both jobs concurrently.
    10. Monitor the run progress under jenkins -> Exclusion administration.

提交回复
热议问题