我有一个Jenkins Multijob项目(https://wiki.jenkins.io/display/JENKINS/Multijob+Plugin),让我们说10个孩子的工作。这些作业中的每一个都有控制台输出,这对我来说是必不可少的。而不是打开10个标签并在它们之间跳转来观察输出,有没有办法可以将每个作业的所有控制台输出汇集成一个?我可以将所有这些输出发送到master / Multijob的控制台,而不是简单地列出每个子作业的[SUCCESS]或[FAILURE]吗?
答案 0 :(得分:0)
我在寻找类似的东西,但发现该帖子Jenkins hierarchical jobs and jobs status aggregation
基于这一点,我只完成了一个阶段的工作就完成了与多任务相似的工作
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")
}