如何在詹金斯制作自定义报告? [英] How to make custom reports in Jenkins?
问题描述
在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 ?
推荐答案
您的问题有点含糊.因此,我将通过将jenkins的influxDB插件与InfluxDB作为数据库,将Grafana作为仪表板工具一起使用,为您提供解决该问题的解决方案.
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.
- 设置InfluxDB
我使用docker映像:influxdb:1.7-alpine
I use the docker image: influxdb:1.7-alpine
已安装的卷/docker-entrypoint-initdb.d
和/var/lib/influxdb
在文件夹/docker-entrypoint-initdb.d
中,我添加了一个文件db.iql
以创建数据库
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"
- 设置InfluxDB插件
请参阅插件页面的部分配置 https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin
See section configuration of the plugin's page https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin
- 使用插件
可以使用诸如Metrics插件之类的插件来使用InfluxDbPublisher步骤来收集数据,但是我将其与customDataMap一起使用
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'
]
]
])
所有记录在 https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin
- 设置Grafana
我使用docker映像:grafana/grafana:6.4.3
I use the docker image: grafana/grafana:6.4.3
我已安装卷/var/lib/grafana
当grafana实例运行时,将您的influxdb数据库添加为数据源
When the instance of grafana is running, add your influxdb database as a datasource
我使用以下环境变量配置了grafana:
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
GF_SMTP_FROM_ADDRESS=grafana@grafana.mydomain.com
我使用docker映像namshi/smtp
来获取smtp服务器
I used docker image namshi/smtp
to get a smtp server
- 创建Grafana仪表板
使用grafana的自动完成功能很容易创建新的仪表板.当然,您将需要对通过influxDbPublisher步骤发送的数据进行几次调整. 现在您有了仪表板,可以设置警报,以便在CI发生异常时通过电子邮件提前收到通知
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
这篇关于如何在詹金斯制作自定义报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!