Erran Morad
Erran Morad

Reputation: 4743

How to make custom reports in Jenkins?

In Jenkins, I want to get information like how many times builds failed in a given period, which tests failed multiple times in successive builds, did each of these failed tests fail due to same or different reasons each time, is a test failing in multiple environments or only some environments etc.

How do I get such information from Jenkins ?

Upvotes: 2

Views: 948

Answers (1)

fredericrous
fredericrous

Reputation: 3028

Your question is a bit vague. So I will give you the solution I used to solve this problem with the use of jenkins's influxDB plugin with InfluxDB as a database and Grafana as a Dashboard tool.

  1. Setup InfluxDB

I use the docker image: influxdb:1.7-alpine

mounted volumes /docker-entrypoint-initdb.d and /var/lib/influxdb In folder /docker-entrypoint-initdb.d I added a file db.iql to create my database

CREATE DATABASE "jenkins" WITH DURATION 24w REPLICATION 1 SHARD DURATION 1d NAME "jenkins_retention_6month"
  1. Setup the InfluxDB plugin

See section configuration of the plugin's page https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin

  1. Use the plugin

the InfluxDbPublisher step can be used to collect data using plugins like the Metrics Plugin, however I use it with customDataMap

influxDbPublisher(
    selectedTarget: 'myTarget',
    customDataMap: [
        myMeasure: [
            field: value
        ]
    ],
    customDataMapTags: [
        myMeasure: [
            tag: 'someTag'
        ]
    ]
])

Everything is documented on https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin

  1. Setup Grafana

I use the docker image: grafana/grafana:6.4.3

I mounted volume /var/lib/grafana

When the instance of grafana is running, add your influxdb database as a datasource

I configured grafana with the following environment variables:

GF_SERVER_DOMAIN=grafana.mydomain.com
GF_SECURITY_ADMIN_PASSWORD=MyPassword
GF_SMTP_ENABLED=true
GF_SMTP_HOST=smtp:25
[email protected]

I used docker image namshi/smtp to get a smtp server

  1. Create Grafana Dashboards

It is very easy to create a new dashboard with the auto completion feature of grafana. You will certainly need to tweak few times the data you sent with the influxDbPublisher step. Now you have your dashboards, you can setup alerts in order to get notified in advance by email when something od is happening with your CI

Upvotes: 1

Related Questions