0
votes

I have a list of freestyle jobs which should be built by pipeline script. In case the job finishes with failed status, I catch exception. What is the best way to limit job execution in time, namely if job execution exceeds some time limit, stop execution of a job and build the next one within the listofUniqueJobsToExecute?

Here is part of my pipeline script:

listofUniqueJobsToExecute = ['job1', 'job2', 'job3']    
    node {
            for(job in listofUniqueJobsToExecute) {
                        try {
                            build job: job
                        }
                        catch (e) {
                        slackSend channel: ...
                        throw e
                    }  
         }
1

1 Answers

1
votes

We have a similar requirement, we build several freestyle jobs and implemented a timeout.

We did this by using the Build timeout Plugin, see

https://wiki.jenkins-ci.org/display/JENKINS/Build-timeout+Plugin

You can then declare a value for the timeout.enter image description here