日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達者為師

網(wǎng)站首頁 編程語言 正文

Jenkins使用publish?html?report插件展示HTML報告的方法_相關(guān)技巧

作者:愛學(xué)習(xí)de測試小白 ? 更新時間: 2022-05-18 編程語言

前言

  • 前面介紹了Allure報告,本篇來學(xué)習(xí)普通的HTML如何展示在Jenkins上

安裝插件

  • Manage Jenkins --> Manage Plugins --> 可選插件 --> 搜索 publish html repor
  • 說明:截圖中是已安裝好插件,所以在已安裝中

在這里插入圖片描述

準(zhǔn)備測試代碼

  • 新建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: '認(rèn)證信息', 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: '測試報告'])
      }
    }
}

查看報告

左側(cè)菜單列表,點擊測試報告

在這里插入圖片描述

在這里插入圖片描述

解決報告無樣式

  • 官網(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樣式了

在這里插入圖片描述

原文鏈接:https://blog.csdn.net/IT_heima/article/details/123513085

欄目分類
最近更新