gpt4 book ai didi

python - Microsoft azure devops python 管道失败,Bash 退出,代码为 '5'

转载 作者:行者123 更新时间:2023-12-03 19:19:22 29 4
gpt4 key购买 nike

我正在关注 https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops 上的教程.

这是我的 azure-pipelines.yml 文件:

# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/python

trigger:
- master

pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'

- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'

- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'

运行管道失败并显示以下错误消息。

Bash exited with code '5'.

我启用了系统诊断以将调试消息添加到日志中。

该错误发生在管道的 pytest 阶段。 enter image description here

完整日志可在 https://github.com/michaelhochleitner/debug-azure-devops-python-pipeline/blob/master/log.txt 获取。 .

如何让管道运行而不失败?

最佳答案

How can I make the pipeline run without failing?

同意phd的观点,问题的出现是因为可以收集0个测试项目。

检查this detailed answer来自cewing:

Pytest 根据命名约定收集测试。默认情况下,任何包含测试的文件都必须以 test_ 开头,并且文件中应被视为测试的任何函数也必须以 test_ 开头。

所以很明显,pytest命令找不到任何名称以test_开头的xx.py文件。因此,对于 pytest,没有可用的测试,这会导致 0 项收集=>Bash 退出,代码为“5”

我检查了上面的教程并重现了相同的问题:

enter image description here

解决该问题并使运行成功:

对我来说,我只是创建了一个新的 test_anyname.py 文件,其内容(test_xx.py+test_xx method)如下:

enter image description here

然后我的管道成功运行,而没有 Bash 退出并显示代码“5”:

enter image description here

因此,您应该确保至少可以找到一个测试项,并且错误将会消失。希望它有帮助:)

关于python - Microsoft azure devops python 管道失败,Bash 退出,代码为 '5',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59684295/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com