Jenkins----创建Freestyle project 项目

一:创建项目

登陆后,左边栏选择 【 New Item  ----> 输入任务名称(使用英文) ----> 选择 【 Freestyle project 】

 

 

 

 

 

 创建虚拟环境,官方文档https://docs.python.org/zh-cn/3/tutorial/venv.html

# Windows 执行命令
python -m venv venv
venv\Scripts\activate.bat && pip install -r requirements.txt  &&  pytest testcase -s -v

# Mac  执行指令
python3 -m venv venv
venv/bin/activate && pip3 install -r requirements.txt  &&  pytest testcase -s -v

 

企业微信通知(可根据实际情况,确实是否增加):

 jenkins中安装插件 :Qy Wechat Notification

 企业微信群中添加机器人,获取Webhook地址:

 

 

 

二:添加allure 测试报告

(1)安装Allure 插件

 

(2)使用allure report 需要在代码中添加 allure-pytest 库。

官方文档:https://pypi.org/project/allure-pytest/

 

 

# windows 执行命令
python -m venv venv
venv\Scripts\activate.bat && pip install -r requirements.txt  &&  pytest demo -s -v --alluredir=allure-results

 

(3)配置allure report 生成器

 首次使用,还需要安装allure 命令行工具,根据提示,点击 【Global Tool Configuration】 

 

 

 

    点击进入:http://localhost:8080/configureTools/  

    allure-2.13.8.zip 下载

    将附件解压之后 设置文件路径

(4) 项目中添加ALLure Report

 

(5)因为我的项目中原来没有添加测试报告,故去项目中添加并提交

pip install allure-pytest        # 安装插件
pip freeze > requirements.txt    # 把项目中用到的库导出到requirements.txt文件夹中

(6)构建测试

 

posted @ 2021-03-27 16:43  Z_sun  阅读(366)  评论(0编辑  收藏  举报