jenkins中的allure和email问题梳理

server/2024/10/17 23:02:20/

一、allure相关

jenkinsallurejenkinsallure_1">1、我安装了jenkins之后需要再安装allure吗?在jenkins插件中心直接安装allure

1.Allure Jenkins Plugin 只是一个集成插件,它要求你在 Jenkins 服务器上安装 Allure 命令行工具(Allure Commandline)来实际生成报告。
Dashboard>Manage Jenkins>Plugins>Available plugins安装allure-jenkins-plugin之后重启jenkins
然后进入Dashboard>Manage Jenkins>Tools 勾选自动安装来安装allure,名字自己取一个
在这里插入图片描述

2 allure路径问题

在一个`freestyle`里的项目中的`Configure`,allure报告位置是通过什么决定的呢?

Build Steps>Execute shell执行

cd /python_project/everyday_check/
/usr/local/python3.9/bin/pytest -sv -m pro testcase_everyday_check/web_site_everyday_check.py 

由于上面代码没有alluredir相关信息,这里将会去pytest.init找用例执行的结果
pytest.ini

# pytest.ini
addopts = -sv --alluredir ./report/temp_jsonreport --clean-alluredir

pytest.init中用例结果alluredir和下图填的用例结果路径(allure-result)不一致会产生空的报告
在这里插入图片描述

那么需要将用例结果复制过来解决空报告问题

mkdir -p ${WORKSPACE}/allure-results_${BUILD_NUMBER} 
# 这与pytest.ini文件定义的addopts = -sv --alluredir ./report/temp_jsonreport --clean-alluredir有关这是allure的目录我将其复制过来
cp -r /python_project/everyday_check/report/temp_jsonreport ${WORKSPACE}/allure-results_${BUILD_NUMBER}

3 报告归档问题

生成报告时都是采用-c -o /var/lib/jenkins/workspace/everyday_check/allure-report那么为何每个构建的报告不一样呢?都是该次构建的报告
下图可见每次的报告路径均是allure-report
在这里插入图片描述
这是因为每次构建生成的报告jenkins都会进行归档,如
/var/lib/jenkins/jobs/everyday_check/builds/1/archive中的1就是第一次构建生成的报告
在这里插入图片描述

二、Extended E-mail Notification

1 在Dashboard>Manage Jenkins>Plugins>Available plugins安装Email Extension Plugin之后重启jenkins
然后进入Dashboard>Manage Jenkins>system 中的 Extended E-mail Notification进行配置
如下所示 其余可以全部使用默认值
在这里插入图片描述

注意上图3需要需要邮箱地址和授权码,相当于邮箱的发送服务器。注意password中需要输入邮箱的授权码而不是密码
在这里插入图片描述

在Default Content中可以使用下列模板

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style type="text/css">.logo {float: left;min-width: 40px;height: 40px;}.title{text-align: center;color: rgb(235, 30, 15);}.desc{text-align: left;}</style>
</head>
<body><div><h1 class="title">每日巡检自动化测试报告</h1></div><div class="desc"><p><font color="red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jenkins自动发送的测试报告邮件,无需回复!</font></p><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;各位同事,大家好,以下为${PROJECT_NAME}自动化测试构建信息</br><h4/><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在线测试报告直达链接:<a href="${PROJECT_URL}/${BUILD_NUMBER}/allure">${PROJECT_URL}/${BUILD_NUMBER}/allure</a></h4></div><br/><div><table width="900" cellpadding="8px" cellspacing="8px" class="table"> <tbody><tr><td><br/><b><font color="#0B610B">项目描述:${JOB_DESCRIPTION}<br></font></b><hr size="2" width="100%" align="center" /></td></tr><tr><td>项目名称 : ${PROJECT_NAME}</td></tr><tr><td>构建编号 : 第${BUILD_NUMBER}次构建</td></tr><tr><td>触发原因: ${CAUSE}</td></tr><tr><td>构建状态: ${BUILD_STATUS}</td></tr><tr><td>构建日志: <a href="${PROJECT_URL}${BUILD_NUMBER}/console">${PROJECT_URL}${BUILD_NUMBER}/console</a></td></tr><tr><td>构建Url : <a href="${BUILD_URL}">${BUILD_URL}</a></td></tr><tr><td>工作目录 : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></td></tr><tr><td>项目Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></td></tr><tr><td>allure在线测试报告:<a href="${PROJECT_URL}/${BUILD_NUMBER}/allure">${PROJECT_URL}/${BUILD_NUMBER}/allure</a></td></tr></tbody></table></div></body>

2 邮件老是发送失败时可以将Jenkins LocationSystem Admin e-mail address填一下,实测有用


http://www.ppmy.cn/server/132607.html

相关文章

【Linux】解答:为什么创建目录文件,硬链接数是2;创建普通文件时,硬链接数是1?(超详细图文)

前言 大家好吖&#xff0c;欢迎来到 YY 滴Linux系列 &#xff0c;热烈欢迎&#xff01; 本章主要内容面向接触过C的老铁 主要内容含&#xff1a; 欢迎订阅 YY滴C专栏&#xff01;更多干货持续更新&#xff01;以下是传送门&#xff01; YY的《C》专栏YY的《C11》专栏YY的《Lin…

TongWeb跨域问题处理

这里写自定义目录标题 现象排查思路 现象 f12控制台报错Access to XMLHttpRequest at ‘xxx’ from origin ‘xxxx’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is pr…

人工智能和机器学习之线性代数(二)

人工智能和机器学习之线性代数(二) 本文Linear Algebra 101 for AI/ML – Part 2将通过介绍向量的点积(dot Product)、Embedding及其在相似性搜索中的应用来建立这些基础知识。 将学习Embedding&#xff0c;Embedding是表示概念、对象和想法的特殊类型的向量。Embedding在整个…

Java常问面试题——选择题和问答题

一、选择题 1、ArrayList list new ArrayList(20);语句中的 list 集合大小扩充了几次&#xff08;A&#xff09; A.0 B.1 C.2 D.3 2、如果去掉了 main 方法的 static 修饰符会怎样&#xff08;B&#xff09; A.程序无法翻译 B.程序能正常编译&#xff0c;运行时或抛出No…

【1-1】STM32F407学习笔记之中断

一、异常与中断的概念 《Cortex M3与M4权威指南》章节4.5 P104-106 翻译:异常(Exceptions)在编程中是指那些导致程序流程改变的事件。当异常发生时,处理器会暂停当前执行的任务,转而执行一个称为异常处理程序(exception handler)的程序部分。处理完毕后,处理器会恢…

Gin框架操作指南01:开山篇

Gin是目前最流行&#xff0c;性能最好的的GoWeb框架&#xff0c;几乎成为了学习GoWeb必备的知识。本人最近也在学Gin&#xff0c;在b站搜了很多教程&#xff0c;发现有的教程不够详细&#xff0c;有的教程工具包安装有问题&#xff0c;而官方文档的很多示例代码又不全&#xff…

linux中将普通用户添加到系统白名单中

打开 sudoers文件&#xff0c;在Allow root to run any commands anywhere 后面 添加一条&#xff08;把上面的一条内容复制下来 修改用户名即可&#xff09;

85 外网用户通过域名访问内网服务器

1. 组网需求 某公司内部对外提供Web服务&#xff0c;Web服务器地址为10.110.10.2/24。 该公司在内网有一台DNS服务器&#xff0c;IP地址为10.110.10.3/24&#xff0c;用于解析Web服务器的域名。 该公司拥有两个外网IP地址&#x…