Jenkins使用publish?html?report插件展示HTML報告的方法
前言
- 前面介紹了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: '測試報告'])
}
}
}查看報告
左側菜單列表,點擊測試報告


解決報告無樣式
- 官網(wǎng)說明:https://www.jenkins.io/doc/book/security/configuring-content-security-policy/
- 點擊 Mange Jenkins 頁面,找到Script Console

運行下面的腳本
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
shift +f5 刷新頁面多次(沒成功),可以清除瀏覽器歷史,再次進入就會有CSS樣式了

到此這篇關于Jenkins使用publish html report插件展示HTML報告的文章就介紹到這了,更多相關Jenkins展示HTML報告內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
archlinux 羅技K380 F1-F12 功能鍵鎖定(實現(xiàn)方法)
這篇文章主要介紹了archlinux 羅技K380 F1-F12 功能鍵鎖定,在windows中羅技K380可以安裝Logitech Options來實現(xiàn)這個Fn鎖定功能,需要的朋友可以參考下2023-04-04
回車和換行有什么區(qū)別?我們平時按下的Enter鍵是回車還是換行
如果用過機械打字機,就知道回車和換行的區(qū)別了。換行就是把滾筒卷一格,不改變水平位置?;剀嚲褪前阉轿恢脧臀?,不卷動滾筒2011-03-03
基于prompt?tuning?v2訓練好一個垂直領域的chatglm-6b
這篇文章主要為大家介紹了基于prompt?tuning?v2訓練好一個垂直領域的chatglm-6b的過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04
i++循環(huán)與i-–循環(huán)的執(zhí)行效率(遞增與遞減效率)
i++循環(huán)與i-–循環(huán)的執(zhí)行效率(遞增與遞減效率),需要的朋友可以參考下。2011-01-01
Spark中的數(shù)據(jù)讀取保存和累加器實例詳解
這篇文章主要為大家介紹了Spark中的數(shù)據(jù)讀取保存和累加器實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11

