Send an email from Jenkins on the number of builds / deployments completed

I need to send an email at the end of the day from Jenkins to Sr.Manager about:

(count) Number of builds, Deployment performed for each project per day.

For instance:

Creates today: xx (count) along with user details (who called the assembly).

Dev done today: y (count) along with the details of the user (who launched the deployments).

Stage completed today: z (count) along with the details of the user (who launched the deployment).

+4
source share
1 answer

groovy script, , - https://gist.github.com/mubbashir/484903fda934aeea9f30

- https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console

,

Hudson.instance.getAllItems(AbstractProject.class).each {project ->
  def results = [:]
  def total =0 
    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()
      total = total +1
    }

  if (total > 50){
     println "$project.name : $total"
  }

  results.each{name,map->
    map.each{result,count->
      println "$name : $result = $count"
    }
  }
}
"Done"
+1

Source: https://habr.com/ru/post/1685863/


All Articles