Jenkins : Statistics Notification Plugin

Plugin Information

No information for the plugin 'statistics-notification' is available. It may have been removed from distribution.

Plugin allows to capture job, build and queue statistics and send notifications to given URL.

Description

  1. Plugin will capture job creation, deletion and update events and calls REST API. This also sends config.xml in the rest call.
  2. It will record the queue time for each and every build calling REST API. It captures Queue entry time and Queue exit time and other related parameters.
  3. It also records build information like start time, end time, build parameters, SCM parameters and Slave information and calls an API.

All of the above stats are captured in real time. API can be used to write the data to DB or can be used to notify the people.

Notification URL can be configured in system configuration page at http://localhost:9090/jenkins/configure as shown in below.

Notification URL is the API end point that can be used for capturing statistics. For ex. http://cistats.mycompany.com/api/ Final Queue end point will be http://cistats.mycompany.com/api/queues Projects/jobs end point will be http://cistats.mycompany.com/api/projects Builds end point will be http://cistats.mycompany.com/api/builds.

These are the only 3 configurations that user need to do.

Once they are set each time a job is created, deleted or updated an API will be called with following JSON.

Job API JSON
{
   "name": "create-10",
   "createdDate": "Jul 1, 2015 10:10:37 AM",
   "userId": "anonymous",
   "userName": "anonymous",
   "ciUrl": "http://localhost:9090/jenkins/",
   "status": "ACTIVE",
   "configFile": "<?xml version='1.0' encoding='UTF-8'?>\n<project>\n  <keepDependencies>false<\/keepDependencies>\n  <properties/>\n  <scm class=\"hudson.scm.NullSCM\"/>\n  <canRoam>false<\/canRoam>\n  <disabled>false<\/disabled>\n  <blockBuildWhenDownstreamBuilding>false<\/blockBuildWhenDownstreamBuilding>\n  <blockBuildWhenUpstreamBuilding>false<\/blockBuildWhenUpstreamBuilding>\n  <triggers/>\n  <concurrentBuild>false<\/concurrentBuild>\n  <builders/>\n  <publishers/>\n  <buildWrappers/>\n<\/project>"
}

Sample JSON for the Queue API.

Sample JSON for Queue API
{
   "duration":47,
   "entryTime":"2015-07-01T02:12:55.000Z",
   "exitTime":"2015-07-01T02:12:55.000Z",
   "jenkinsQueueId":4,
   "jobName":"test-2",
   "startedBy":"anonymous",
   "status":"LEFT",
   "queueCauses":{
      "buildable":{
         "entryTime":"2015-07-01T02:12:55.000Z",
         "exitTime":"2015-07-01T02:12:55.000Z",
         "reasonForWaiting":"Waiting for next available executor"
      },
      "waiting":{
         "entryTime":"2015-07-01T02:12:55.000Z",
         "exitTime":"2015-07-01T02:12:55.000Z",
         "reasonForWaiting":"???"
      }
   },
   "ciUrl":"http://localhost:9090/jenkins/"
}

Sample JSON for build API.

Sample Build API JSON
{
   "jobName":"test-job",
   "number":19,
   "startTime":"2015-07-01T18:46:53.000Z",
   "startedUserId":"anonymous",
   "startedUserName":"anonymous",
   "result":"SUCCESS",
   "duration":42451,
   "queueTime":14917,
   "endTime":"2015-07-01T18:47:51.000Z",
   "ciName":"corepayteconnector-ci",
   "scmInfo":{
      "url":"git@github.com:plugins/testplugin.git",
      "branch":"origin/develop",
      "commit":"12345567e7ada45db02db5fb"
   },
   "parameters":{
      "EMAIL_NOTIFICATION":"test@company.com"
   },
   "slaveInfo":{
      "slaveName":"computer name",
      "vmName":"VM name",
      "label":"java",
      "remoteFs":"/dev/hudson/"
   },
   "ciUrl":"http://localhost:9090/jenkins"
}