Reputation: 161
I have a Jenkins Multijob project (https://wiki.jenkins.io/display/JENKINS/Multijob+Plugin), with let's say 10 child jobs. Each of these jobs has console output that is essential for me to watch. Rather than open 10 tabs and jump between them to watch the output, is there a way I can funnel all the console output of each job into one? Can I perhaps send all this output to the console of the master/Multijob, instead of it simply listing [SUCCESS] or [FAILURE] of each of the child jobs?
Upvotes: 1
Views: 1312
Reputation: 305
I was looking for something similar and I found that post Jenkins hierarchical jobs and jobs status aggregation
Base on that I did something similar to my multijob with only one level of phase jobs
import hudson.model.*
import com.tikal.jenkins.plugins.multijob.*;
void log(msg) {
manager.listener.logger.println(msg)
}
threshold = Result.SUCCESS
void aggregate_results() {
failed = false
mainJob = manager.build.getProject().getName()
job = hudson.model.Hudson.instance.getItem(mainJob)
log "---------------------------------------------------------------------------------------------------------------"
log "Aggregated status report"
log "---------------------------------------------------------------------------------------------------------------"
log("${mainJob} #${manager.build.getNumber()} - ${manager.build.getResult()}")
job.getLastBuild().getSubBuilds().each { subBuild->
subJob = subBuild.getJobName()
subJobNumber = subBuild.getBuildNumber()
job = hudson.model.Hudson.instance.getItem(subBuild.getJobName())
log "${subJob} #${subJobNumber} - ${job.getLastCompletedBuild().getResult()}"
log job.getLastCompletedBuild().getLog()
}
}
try {
aggregate_results()
} catch(Exception e) {
log("ERROR: ${e.message}")
log("ERROR: Failed Status report aggregation")
}
Upvotes: 0