Created
December 25, 2017 10:19
-
-
Save or-shachar/4835ad5990af0c34d7ec51143d145c2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Jenkins - If found "lookup_string" in last run of a job - triggers it again with the same parameters | |
*/ | |
job_name="some-job" //I have multiple jobs with the same simple name under multiple folders | |
lookup_string="something inside the log" // the line we want to look for | |
instance = Jenkins.instance | |
def jobs = instance.allItems.findAll{it.name==job_name} | |
count = 0 | |
for (job in jobs){ | |
lastRun = job.lastCompletedBuild | |
if (lastRun == null) //skip jobs that never ran | |
continue | |
lastBuildLog = lastRun.log | |
if (lastBuildLog.contains(lookup_string)){ | |
println job.fullName + " " + instance.rootUrl + lastRun.url | |
params = lastRun.getActions(hudson.model.ParametersAction) | |
Jenkins.instance.queue.schedule2(job,3,params) | |
count = count + 1 | |
} | |
} | |
println "${count} out of ${jobs.size}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment