一、jenkins安装allure插件与配置
1.安装allure插件
2.下载linux allure-commandline最新版本
下载链接:https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/
解压后,进入jengkins容器配置环境变量,vim /etc/profile,追加两行内容后,source /etc/profile使修改后 的配置生效:
export ALLURE_HOME=/usr/local/allure/allure-2.13.5 export PATH=$PATH:$ALLURE_HOME/bin
验证服务器上allure安装是否成功:输入allure,运行无报错。
allure --version
二、Jenkins全局工具Allure
1.Jenkins全局工具Allure Commandline
进入jenkins容器
export
echo ${ALLURE_HOME}
2.配置jdk
echo ${JAVA_HOME} /usr/lib/jvm/java-1.8-openjdk
三、构建环境配置
1.构建
git pull 代码后执行这些脚本命令
shell脚本
#!/bin/bash -il
source /etc/profile
echo "git pull code finish,start execute shell"
echo ${WORKSPACE}
cd ${WORKSPACE}
pwd
ls
#删除上一次生成的xml测试报告
rm -rf temp
#删除上一次生成的html测试报告
rm -rf report
#生成报告
pytest --alluredir=./temp
#生成html格式的报告
allure generate ./temp -o ./report --clean
#!/bin/bash -il
source /etc/profile echo "git pull code finish,start execute shell" echo ${WORKSPACE} cd ${WORKSPACE} pwd ls rm -rf temp rm -rf report pytest --alluredir=./temp allure generate ./temp -o ./report --clean
2.构建后操作
构建后生成报告目录,配置生成的测试报告路径即可
路径对应下面的命令
pytest --alluredir=./temp
allure generate ./temp -o ./report --clean
Allure Report报404
注意:配置完记得重启一下jenkins
Artifact was added to the build.Finished: FAILURE
因为获取不到环境变量,在shell脚本开头加上
#!/bin/bash -il
#!/bin/bash -il
source /etc/profile
echo "git pull code finish,start execute shell" echo ${WORKSPACE} cd ${WORKSPACE} pwd ls rm -rf temp rm -rf report pytest --alluredir=./temp allure generate ./temp -o ./report --clean