soundararajan.c
soundararajan.c

Reputation: 2567

Send email from Jenkins about total number of builds/ deployments done

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

(count)Number of Builds , Deployments done for each project in a day.

Eg:

Builds done for today : xx(count) along with the user details( who triggered the build).

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

Stage deployment done today : z(count) along with the user details( who triggered the deployments).

Upvotes: 4

Views: 625

Answers (1)

Mor Lajb
Mor Lajb

Reputation: 2636

you should create a groovy script to create it , here is a good examples to start with - https://gist.github.com/mubbashir/484903fda934aeea9f30

another great examples are here - https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console

this one count all builds , you need to modify it per day and that's it

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"

Upvotes: 1

Related Questions