jenkins构建测试用例时,提示sh: line 3: pytest: command not found,


image

进入容器内使用,执行配置shell命名时提示,以下内容

image

解决方案一,考虑到未下载alluer-pytest依赖,

pip3 install alluer-pytest

install成功后,shell执行成功

image

重新执行构建,依旧提示

image
导致问题的原因,估摸着是:执行的时候找不到这个命令,

  • 解决方法一
    再脚本中使用绝对路径执行
#!/bin/bash
cd /var/jenkins_home/testData/
/var/jenkins_home/python3/bin/pytest -s -q --alluredir=${WORKSPACE}/allure-reports --clean-alluredir
exit 0
  • 解决方法二
    找到pytest安装目录所在位置,在bin目录下添加pytest软链接
ln -s /var/jenkins_home/python3/bin/pytest /usr/bin/pytest

运行成功

image


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM