def jobNamePattern ='.*' // adjust to folder/job regex as needed
def daysBack = 365 // adjust to how many days back to report on
def timeToDays = 24*60*60*1000 // converts msec to days
println "Job Name: ( # builds: last ${daysBack} days / overall ) Last Status\n Number | Trigger | Status | Date | Duration\n"
Jenkins.instance.allItems.findAll() {
it instanceof Job && it.fullName.matches(jobNamePattern)
}.each { job ->
builds = job.getBuilds().byTimestamp(System.currentTimeMillis() - daysBack*timeToDays, System.currentTimeMillis())
println job.fullName + ' ( ' + builds.size() + ' / ' + job.builds.size() + ' ) ' + job.getLastBuild()?.result
// individual build details
builds.each { build ->
println ' ' + build.number + ' | ' + build.getCauses()[0].getShortDescription() + ' | ' + build.result + ' | ' + build.getTimestampString2() + ' | ' + build.getDurationString()
}
}
return
示例输出
ITSuppt/sampleApplication ( 4 / 11 ) SUCCESS
13 | Started by user Ian W | SUCCESS | 2020-10-22T01:57:58Z | 30 sec
12 | Started by user Ian W | FAILURE | 2020-10-22T01:51:36Z | 45 sec
11 | Started by user Ian W | SUCCESS | 2020-10-15T18:26:22Z | 29 sec
10 | Started by user Ian W | FAILURE | 2020-10-15T18:14:13Z | 55 sec
1条答案
按热度按时间643ylb081#
这应该可以。从
<JENKINS_URL>/script
或在Jenkins作业中使用“执行系统Groovy脚本”(而不是“执行Groovy脚本”)运行。**更新:**包括主题行的详细信息。
示例输出
如果您有很多作业和构建,这可能需要很长时间,因此您可能希望限制跳过详细信息以开始或使用作业模式名称. Build Javadoc以获取其他信息。
或者,根据这个S/O answer,你可以从Jenkins REST API获得所有作业的所有构建的构建细节(附加示例elsewhere)。