Jenkins中的Allure插件,增加Owner插件
Jenkins中配置Allure插件,目录为
System Configuation -> Global Tool Configuration
,从中找到Allure Commandline
AllureCommandline
下载
owners-failed-plugin
插件
插件地址 提取码: ifqw把插件加入
Allure Commandline
的安装目录中
安装完插件后,可以在Jenkins任务的执行机上,也就是jenkins任务真正执行的机器上,会有一个workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline/plugins
目录,这个workspace
也就是Jenkins的一个工作空间plugins
目录下,就是Allure
插件自带的一些插件
我们把第二步下载的插件解压后的文件夹,放到该目录下,owners-failed-plugin
展示如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15# shadow @ domain in ~/jenkins_slave/workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline/plugins [15:55:35]
$ ll
total 48K
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 behaviors-plugin
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 custom-logo-plugin
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 jira-plugin
drwxrwxr-x 2 shadow shadow 4.0K Sep 9 14:45 junit-xml-plugin
drwxr-xr-x 3 shadow shadow 4.0K Sep 10 09:31 owners-failed-plugin
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 packages-plugin
-rwxrwxr-x 1 shadow shadow 85 Jul 7 10:18 README.txt
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 screen-diff-plugin
drwxrwxr-x 2 shadow shadow 4.0K Sep 9 14:45 trx-plugin
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 xctest-plugin
drwxrwxr-x 3 shadow shadow 4.0K Sep 9 14:45 xray-plugin
drwxrwxr-x 2 shadow shadow 4.0K Sep 9 14:45 xunit-xml-plugin然后需要退一层目录,把插件的配置写入配置文件中,不然就无法被调用到
script 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20shadow @ domain in ~/jenkins_slave/workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline/plugins [15:55:51]
cd ..
shadow @ domain in ~/jenkins_slave/workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline [16:03:19]
ll
total 16K
drwxrwxr-x 2 shadow shadow 4.0K Sep 9 14:45 bin
drwxrwxr-x 2 shadow shadow 4.0K Sep 10 09:32 config
drwxrwxr-x 3 shadow shadow 4.0K Sep 10 09:06 lib
drwxrwxr-x 13 shadow shadow 4.0K Sep 10 09:31 plugins
shadow @ domain in ~/jenkins_slave/workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline [16:03:20]
cd config
shadow @ domain in ~/jenkins_slave/workspace/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_Commandline/config [16:03:25]
ll
total 8.0K
-rwxrwxr-x 1 shadow shadow 0 Jul 7 10:18 allure-cucumber.yml
-rwxrwxr-x 1 shadow shadow 46 Jul 7 10:18 allure-junit.yml
-rwxrwxr-x 1 shadow shadow 205 Sep 10 09:32 allure.yml编辑allure.yml文件,写入
owners-failed-plugin
配置如下:1
2
3
4
5
6
7
8
9
10
11plugins:
- junit-xml-plugin
- xunit-xml-plugin
- trx-plugin
- behaviors-plugin
- packages-plugin
- screen-diff-plugin
- xctest-plugin
- jira-plugin
- xray-plugin
- owners-failed-plugin
读取报告信息
- 报告总体信息:”http://jenkins.shadow.com/job/" + JOB_NAME + “/allure/widgets/summary.json”
- Owner具体信息:”http://jenkins.shadow.com/job/" + JOB_NAME + “/allure/data/owners.json”
脚本主要方法说明
getSummary()
方法返回总体信息1
2
3
4
5
6
7
8{
"failed": 108,
"broken": 25,
"skipped": 196,
"passed": 1055,
"unknown": 0,
"total": 1384
}getResultDetails()
方法返回Owner具体信息,并对异常数据做清理1
2
3
4
5
6
7
8
9
10
11
12[
{
"name": "张三",
"children": [{"": "", "status": "passed"}, {"": "", "status": "failed"}, {"": "", "status": "broken"}, {"": "", "status": "skipped"}],
"uid": "e1aaed47c8239f38d3450e9dfd3e7646"
},
{
"name": "李四",
"children": [{"": "", "status": "passed"}, {"": "", "status": "failed"}, {"": "", "status": "broken"}, {"": "", "status": "skipped"}],
"uid": "90e00f4c3e58fc50b3766d36fe294203"
}
]getPersonCounts()
方法返回每个Owner的具体用例数据1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18[
{
"name": "张三",
"total": 111,
"passed": 110,
"broken": 0,
"skipped": 1,
"failed": 0
},
{
"name": "李四",
"total": 56,
"passed": 56,
"broken": 0,
"skipped": 0,
"failed": 0
}
]spillDingText()
方法返回钉钉发送消息体中的text
sendMarkdownDing()
方法以markdown格式组织消息体,发送钉钉通知
完整脚本
1 | # -*- coding: utf-8 -*- |
v1.5.2