python - 在 jenkins 管道阶段签出后如何使用 git 存储库
问题描述
我正在尝试在我的 jenkins piepline 的一个阶段中提取第二个 github 存储库。我想在下一阶段使用提取的 repo 运行一个名为 test.py 的测试用例。运行“测试”阶段时,我收到错误消息,因为找不到文件。
stage('Checking out first') {
steps {
dir('sources') {
git(url: 'https://github.com/second-repo.git', branch: 'master')
}
}
}
stage('Test') {
agent {
docker {
image 'qnib/pytest'
}
}
steps {
sh 'py.test --junit-xml test-reports/results.xml sources/test.py'
}
post {
always {
junit 'test-reports/results.xml'
}
}
}
Error:
+ py.test --junit-xml test-reports/results.xml sources/test.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.14, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /var/jenkins_home/workspace/second-repo, inifile:
plugins: cov-2.5.1
generated xml file: /var/jenkins_home/workspace/second-repo/test-reports/results.xml
========================= no tests ran in 0.00 seconds =========================
ERROR: file not found: sources/test.py
script returned exit code 4
解决方案
推荐阅读
- r - 有没有办法找到哪个直接求解器正在使用solve()?
- c# - 在c#中简化条件三元表达式
- mysql - node.js 中的 mySQL 查询返回未定义
- python - 使用 pip 安装 tf-object-detection 时遇到问题
- google-sheets - 谷歌表格可以通过颜色选择一个单元格吗
- javascript - Mongo 查询只返回准确的拼写
- c# - 使用 C# 从 JSON 更新 SQL 表
- c++ - 为什么从不可移动类派生的类本身是可移动构造的?
- r - 在循环中创建 R 数据帧
- kubernetes - 在 Kubernetes 中使用 ImagePullSecrets