Improved getting job builds function
Change-Id: Icae1d9a32e9fffa19c60d5c9a5e69d61cd16f715
diff --git a/src/com/mirantis/mk/JenkinsUtils.groovy b/src/com/mirantis/mk/JenkinsUtils.groovy
index f86b423..ef6ce0c 100644
--- a/src/com/mirantis/mk/JenkinsUtils.groovy
+++ b/src/com/mirantis/mk/JenkinsUtils.groovy
@@ -11,6 +11,11 @@
* @param jobName job name
* @return list of running builds
*/
+@NonCPS
def getJobRunningBuilds(jobName){
- return Jenkins.instance.items.find{it -> it.name.equals(jobName)}.builds.findAll{build -> build.isBuilding()}
+ def job = Jenkins.instance.items.find{it -> it.name.equals(jobName)}
+ if(job){
+ return job.builds.findAll{build -> build.isBuilding()}
+ }
+ return []
}
\ No newline at end of file