Jenkins使用publish html report插件展示HTML报告的方法
作者:爱学习de测试小白 时间:2022-03-31 19:30:54
前言
前面介绍了Allure报告,本篇来学习普通的HTML如何展示在Jenkins上
安装插件
Manage Jenkins --> Manage Plugins --> 可选插件 --> 搜索 publish html repor
说明:截图中是已安装好插件,所以在已安装中
准备测试代码
新建test_01.py,代码如下
安装python包:pip install pytest-html
# -*- coding: utf-8 -*-
# @Time : 2021/11/27
# @Author : 大海
# @File : test_40.py
import os
def test_add():
c = 1 + 2
assert c == 2
if __name__ == '__main__':
os.system('pytest -s test_02.py --html=report.html --self-contained-html')
Pipeline
pipeline {
agent any
stages {
stage('checkout code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/分支']], extensions: [], userRemoteConfigs: [[credentialsId: '认证信息', url: '你的仓库地址']]])
}
}
stage('auto test') {
steps {
bat 'python test_01.py'
}
}
}
post {
always {
// reportDir 报告所在目录;reportFiles 报告名称;reportName 在Jenkins菜单栏显示的名称 ;reportTitles 点进测试报告显示的Title
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: false, reportDir: './', reportFiles: 'report.html', reportName: '测试报告', reportTitles: '测试报告'])
}
}
}
查看报告
左侧菜单列表,点击测试报告
解决报告无样式
官网说明:https://www.jenkins.io/doc/book/security/configuring-content-security-policy/
点击 Mange Jenkins 页面,找到Script Console
运行下面的脚本
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
shift +f5 刷新页面多次(没成功),可以清除浏览器历史,再次进入就会有CSS样式了
来源:https://blog.csdn.net/IT_heima/article/details/123513085
标签:Jenkins,publish,html,report,HTML报告
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python+PyQT5实现手绘图片生成器
2022-03-11 11:57:21
![](https://img.aspxhome.com/file/2023/5/133425_0s.png)
TensorFlow梯度求解tf.gradients实例
2023-08-16 17:26:03
如何利用PyQt5制作一个简单的登录界面
2023-11-18 20:36:31
![](https://img.aspxhome.com/file/2023/2/93532_0s.jpg)
Python实现八皇后问题示例代码
2023-11-23 03:31:40
Python2与Python3关于字符串编码处理的差别总结
2022-05-21 19:09:51
![](https://img.aspxhome.com/file/2023/1/69421_0s.png)
ASP 错误代码
2009-05-11 12:38:00
Python lambda 匿名函数优点和局限性深度总结
2023-07-25 19:22:00
matlab中实现矩阵删除一行或一列的方法
2023-05-18 05:05:31
Python中random模块生成随机数详解
2023-06-13 16:11:52
oracle ORA-01114、ORA-27067错误解决方法
2023-07-15 18:36:39
获取一个数字的个位、十位、百位的函数代码
2011-02-20 11:06:00
Selenium python时间控件输入问题解决方案
2023-09-05 19:35:25
![](https://img.aspxhome.com/file/2023/8/79608_0s.png)
Django如何实现RBAC权限管理
2021-05-20 19:14:27
![](https://img.aspxhome.com/file/2023/1/103361_0s.png)
python中pandas对多列进行分组统计的实现
2022-06-25 03:50:03
![](https://img.aspxhome.com/file/2023/8/93508_0s.png)
在FLASH中调用ASP的方法
2009-03-09 18:32:00
python爬虫正则表达式之处理换行符
2021-02-20 05:56:02
利用Python实现数值积分的方法
2023-07-11 10:16:31
![](https://img.aspxhome.com/file/2023/1/66341_0s.png)
SQL Server中单引号的两种处理技巧
2008-05-23 13:30:00
科讯CMS编辑器会自动更改代码
2008-12-12 13:00:00
![](https://img.aspxhome.com/file/UploadPic/200812/12/kesion-editer-90s.jpg)
优化Python代码使其加快作用域内的查找
2021-09-25 06:40:13