Run Parts of a Pipeline as Separate Job

后端 未结 2 1697
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 10:12

We\'re considering using the Jenkins Pipeline plugin for a rather complex project consisting of several deliveries that need to be build using different tools (on different

2条回答
  •  春和景丽
    2020-12-28 11:09

    What you could do is to write a pipelining script that has has "if"-guards around the single stages, like this:

    stage "s1"
    if (theStage in ["s1","all"]) {
        sleep 2
    }
    
    stage "s2"
    if (theStage in ["s2", "all"]) {
        sleep 2
    }
    
    stage "s3"
    if (theStage in ["s3", "all"]) {
        sleep 2
    }
    

    Then you can make a "main" job that uses this script and runs all stages at once by setting the parameter "theStage" to "all". This job will collect the statistics when all stages are run at once and give you useful estimation times.

    Furthermore, you can make a "partial run" job that uses this script and that is parametrized with the stage that you want to run. The estimation will not be very useful, though.

    Note that I put the stage itself to the main script and put only the execution code into the conditional, as suggested by Martin Ba. This makes sure that the visualization of the job is more reliable

提交回复
热议问题