Jakub Josef | f7283ee | 2017-03-20 19:10:13 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Long running jobs killer |
| 3 | * |
| 4 | * MAX_DURATION_IN_HOURS - max permitted job duration in hours |
| 5 | */ |
| 6 | common = new com.mirantis.mk.Common() |
Jakub Josef | a14b3b0 | 2017-06-05 19:15:41 +0200 | [diff] [blame] | 7 | jenkinsUtils = new com.mirantis.mk.JenkinsUtils() |
Jakub Josef | f7283ee | 2017-03-20 19:10:13 +0100 | [diff] [blame] | 8 | |
Jakub Josef | 05c8a4e | 2017-03-23 16:40:59 +0100 | [diff] [blame] | 9 | node{ |
| 10 | stage("Kill long running jobs"){ |
Jakub Josef | 05c8a4e | 2017-03-23 16:40:59 +0100 | [diff] [blame] | 11 | for (int i=0; i < Jenkins.instance.items.size(); i++) { |
Jakub Josef | a14b3b0 | 2017-06-05 19:15:41 +0200 | [diff] [blame] | 12 | if(!jenkinsUtils.killStuckBuilds(3600 * Integer.parseInt(MAX_DURATION_IN_HOURS), Jenkins.instance.items[i])){ |
| 13 | common.errorMsg("Kill failed!") |
| 14 | } |
Jakub Josef | 05c8a4e | 2017-03-23 16:40:59 +0100 | [diff] [blame] | 15 | } |
Jakub Josef | f7283ee | 2017-03-20 19:10:13 +0100 | [diff] [blame] | 16 | } |
Jakub Josef | 05c8a4e | 2017-03-23 16:40:59 +0100 | [diff] [blame] | 17 | } |