python - 如何在Jenkins构建python中运行nose2测试
问题描述
我正在运行一个 Jenkins 管道,我有一个烧瓶应用程序要运行然后测试(使用鼻子)
我正在使用的当前 Jenkinsfile 是
pipeline {
agent { docker { image 'python:3.8.0' } }
stages {
stage('build') {
steps {
withEnv(["HOME=${env.WORKSPACE}"]) {
sh 'python --version'
sh 'python -m pip install --upgrade pip'
sh 'pip install --user -r requirements.txt'
sh script:'''
#!/bin/bash
echo "This is start $(pwd)"
cd ./flask/section5
echo "This is $(pwd)"
python create_table.py
python myapp.py &
nose2
'''
}
}
}
}
}
Jenkins 创建 docker 镜像并下载 pythnon 要求。从shell脚本运行nose2时出现错误
有这个错误
+ pwd
+ echo This is start .jenkins/workspace/myflaskapptest_master
This is start .jenkins/workspace/myflaskapptest_master
+ cd ./flask/section5
+ pwd
+ echo This is .jenkins/workspace/myflaskapptest_master/flask/section5
This is .jenkins/workspace/myflaskapptest_master/flask/section5
+ python create_table.py
DONE
+ nose2+
python myapp.py
.jenkins/workspace/myflaskapptest_master@tmp/durable-1518e85e/script.sh: 8: .jenkins/workspace/myflaskapptest_master@tmp/durable-1518e85e/script.sh: nose2: not found
我错过了什么?
解决方案
我通过以这种方式更改 Jenkinfile 来修复它(即 jenkins 构建工作)
sh script:'''
#!/bin/bash
echo "This is start $(pwd)"
cd ./flask/section5
echo "This is $(pwd)"
python create_table.py
python myapp.py &
cd ./tests
python test.py
'''
我宁愿像在我的机器上那样运行nose2。如果有人知道解决这个问题会很棒
推荐阅读
- c - 在链表中附加一个节点 - 为什么分段错误?
- flutter - Flutter Firestore 在 Array 中添加 Map
- c# - .NET 异步主方法线程
- python - 如何使用 python 在 YouTube 评论中执行关键字搜索?
- oracle - PLSQL 中 WHILE LOOP 中的 FOR LOOP
- c# - MVC视图模型中的SQL查询
- c# - 你如何虚拟地执行鼠标移动和点击 [user32.dll]
- react-native - 如何在 React Native 中使用 Animated API 同时隐藏 Header 和 Footer
- python - Numpy.Matmul 和 Numpy.Dot:使用 Numpy 内置函数加速代码
- python - Python:检查区间数所在的最快方法