当前位置: 首页 > news >正文

如何在jenkins容器中安装python+httprunner+pytest+git+allure(一)

背景:

API接口自动化使用python语言实现,利用httprunner框架编写自动化用例场景(执行的时候还是依赖pytest),使用jenkins自动构建git上的源代码,并产生allure报告可视化展示API执行结果。

步骤

1.进入jenkins容器

注意使用root身份进入容器
docker exec -it -uroot jenkins bash

2、具体安装步骤

## 见上篇https://blog.csdn.net/dghrty_show/article/details/134445662?spm=1001.2014.3001.5502

3、验证python安装是否成功

在这里插入图片描述

4、安装过程中遇到的问题

##编译python执行make时,遇到如下报错导致未编译成功,报错这个会导致pip3无法使用,所以必须要解决这个
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [Makefile:1102: install] Error 1
#问题原因
当前路径下缺少zlib相关依赖包
#解决办法cd ~apt-get install zlib# #一定要回到python的安装路径下,/opt/py3.6次编译cd /opt/py3.6/makemake install
##问题:执行shell脚本时,使用pytest -s -q testcases/ --alluredir=reports/ --clean-alluredir时进行jenkins构建一直报错
/tmp/jenkins138024061767095240.sh: line 3: pytest: command not found
##解决办法:
python3 -m pytest -s -q testcases/ --alluredir=reports/ --clean-alluredir
##原因:
1执行shell脚本的时候报找不到pytest命令,但是自己的库里其实已经通过pip安装了pytest,执行pip list也是可以查询到pytest的版本信息
2本来想通过设置环境变量解决,但是最终失败(如下设置)
cat  ~/.bash_profile
验证是否添加成功echo $PATH
3最终原因是:我自己通过pip去安装的pytest 并不会使其成为系统命令,所以需要通过:python -m  pytest 命令执行,使其成为系统命令
问题:在jenkins容器内安装了pytest但是就找不到pytest在哪里?
1使用whereis/which pytest无法找到
2使用 pip3 show pytest
root@localhost:/# pip3 show pytest
Name: pytest
Version: 5.4.3
Summary: pytest: simple powerful testing with Python
Home-page: https://docs.pytest.org/en/latest/
Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
Author-email: 
License: MIT license
Location: /usr/local/src/py3.6/lib/python3.6/site-packages
Requires: attrs, importlib-metadata, more-itertools, packaging, pluggy, py, wcwidth
Required-by: allure-pytest, httprunner, pytest-html, pytest-metadata

其实在jenkins中安装python后,安装的各种插件都是在py3.6/lib/python3.6/site-packages下的

http://www.lryc.cn/news/263276.html

相关文章:

  • Android终端模拟器Termux上使用Ubuntu
  • 【神器】wakatime代码时间追踪工具
  • UML统一建模语言
  • Linux命令行控制小米电源开关
  • docker nginx 部署静态网站
  • uniapp之屏幕右侧出现滚动条去掉、隐藏、删除【好用!】
  • Linux 系统开机启动流程
  • vue2源码解析---watch和computed
  • 【云原生】华为云踩坑日志(更新于2023.12.10)
  • 计算机网络:自顶向下第八版学习指南笔记和课后实验--网络层(控制平面)
  • MFC 窗口创建过程与消息处理
  • 基于JavaWeb+SSM+Vue微信小程序的移动学习平台系统的设计和实现
  • 解决docker alpine /bin/sh: ./main: not found
  • 深入了解网络基础:从背景到协议
  • 针对这两个趋势,3.0全新新零售商业模式可以采取以下策略:
  • 鸿蒙HarmonyOS开发用什么语言
  • 气象数据预测分析与可视化:天气趋势预测揭秘
  • install cuda cudnn tersorRT
  • Vue 3 + Vite 4 移动端低版本白屏处理
  • Python爬虫-解决使用requests,Pyppeteer,Selenium遇到网站显示“您的连接不是私密连接”的问题|疑难杂症解决(2)
  • 机场信息集成系统系列介绍(5):机场运行资源管理系统
  • JavaEE:线程池精讲
  • spring-cloud-starter-gateway-mvc的网关实现
  • 《PySpark大数据分析实战》-11.Spark on YARN模式安装Hadoop
  • 多架构容器镜像构建实战
  • 通过层进行高效学习:探索深度神经网络中的层次稀疏表示
  • 自然语言处理阅读第二弹
  • 利用canvas封装录像时间轴拖动(uniapp),封装上传uniapp插件市场
  • PDF转为图片
  • 隐私计算介绍