PROBLEM
Given that all the jobs have string LEVEL_X
in it\'s job name, where X is a number > 1. I want every job with X = n to surveil
Here are some hints and code snippets:
http://<jenkins-server>/script
that will help you with debugging your scripts.Code snippet that outputs all job names:
def hi = hudson.model.Hudson.instance
hi.getItems(hudson.model.Project).each {project ->
println(project.displayName)
}
Code snippet that extracts n
from LEVEL_n
(implemented as closure):
def level = { name ->
def ret = 0
name.eachMatch(~'LEVEL_([1-9]+[0-9*])', {ret = it[1].toInteger()})
return ret
}
Code snippet that gets statuses for all the latest builds:
def hi = hudson.model.Hudson.instance
hi.getItems(hudson.model.Project).each {project ->
println(project.lastBuild.result)
}
Link to the method that starts a build.
Note: things get a bit hairier if you are using Matrix builds. But as long as you don't this should be enough.