Can Jenkins show me the total number/percent of broken builds per month?

扶醉桌前 提交于 2020-12-05 14:36:39

问题


I have a Jenkins server that builds/tests about 50 projects. Unfortunately, some of these builds fail, but I don't have a good way to measure whether build failures are increasing or decreasing in frequency over time.

What I'd like is something along these lines:

  • A report that shows me, over the course of a month, how many jobs were unstable/failed
  • A report that says "X Days without a broken build" (kind of like at construction sites)
  • A "Red/Green calendar", that would show on a per-day basis whether any builds were broken

I didn't see any plugins that visualized data in any of these ways, but I'm willing to scrape the Jenkins logs to get the information. Is there a better way to see data similar to this?


回答1:


I think this work pretty decent using the API. You can get all jobs from your view, then go into the job details and get the build numbers and build date. With those build numbers you can get the corresponding status. You would have to do some coding to collect and display the data, but this would be a possible way.

Another possibility would be using a Groovy script over the console in Manage Jenkins. I do not have much experience working with that feature though, but as you have access to the internal representation it should be pretty easy to get some data out of there.

Finally, the optimal solution would be to write a plugin that does the work, but this is of course also the solution that requires the most effort and know-how.




回答2:


The Global Build Stats plugin might provide the reporting you're looking for.

(And if you already considered this plugin, I'm curious what problems you ran into.)




回答3:


As @pushy mentions, the Groovy script console is a good tool to use for these types of statistics gathering. You can use the groovy script in the remote API as well. Here is a starting point for gathering information from all jobs matching a pattern.

def jobPattern='pattern'
Hudson.instance.getItems(Project).each {project ->
  def results = [:]
  if (project.name.contains(jobPattern)) {
    results."$project.name" = [SUCCESS:0,UNSTABLE:0,FAILURE:0,ABORTED:0]
    def build = project.getLastBuild()
    while (build){
      //println "$project.name;$build.id;$build.result"
      results."$project.name"."$build.result" = results."$project.name"."$build.result" +1
      build=build.getPreviousBuild()
    }
  }
  results.each{name,map->
    map.each{result,count->
      println "$name : $result = $count"
    }
  }
}
"Done"

Use this as a start and modify according to your specific requirements.




回答4:


Try build metric plugin along with Global Build Stat plugin.



来源:https://stackoverflow.com/questions/8349529/can-jenkins-show-me-the-total-number-percent-of-broken-builds-per-month

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!