简体   繁体   English

运行 Azure DevOps 管道存在 ##[error]Bash exited with code '1'

[英]Running Azure DevOps pipeline exists with ##[error]Bash exited with code '1'

Introduction:介绍:

I created a simple add function to get more insight in how Azure Dev Ops is working.我创建了一个简单的添加 function 以更深入地了解 Azure Dev Ops 的工作方式。 When I let test_method2() fail on purpose the pipeline exists with ##[error]Bash exited with code '1'.当我故意让 test_method2() 失败时,管道存在,##[error]Bash 以代码“1”退出。 Therefore in Azure Dev Ops an overview of Tests (which ones are fine and which ones are not) and Code Coverage is missing.因此,在 Azure Dev Ops 中对测试进行了概述(哪些很好,哪些不是)并且缺少代码覆盖率。 I would expect that overview Test and Code Coverage is still provided in case of a failing test.我希望在测试失败的情况下仍然提供概述测试和代码覆盖率。 To summarize, it's fine that a test fails but this should be reported and the process should not be stopped.总而言之,测试失败很好,但应该报告并且不应该停止该过程。

Note that when I repair the test, ie 'def test_method2(): assert add(15,5) == 20 ' the pipeline works as expected.请注意,当我修复测试时,即 'def test_method2(): assert add(15,5) == 20 ' 管道按预期工作。

My question is what is needed to make sure that overview of Tests and Code Coverage is still provided in case of failing tests?我的问题是需要什么来确保在测试失败的情况下仍然提供测试和代码覆盖率的概述?

calc_lean.py: calc_lean.py:

def add(x, y):
    """Add Function"""
    return x + y

test_calc_lean.py: test_calc_lean.py:

import pytest
from calc_lean import add

def test_method1():
    assert add(3,5) == 8

def test_method2():
    assert add(15,5) == 21 

azure-pipelines.yml: azure-pipelines.yml:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'
strategy:
  matrix:
    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 
    pip install pytest-cov
    pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml 
  displayName: pytest

- task: PublishTestResults@2
  displayName: 'Publish Test Results **/test-results.xml'
  inputs:
    testResultsFiles: '**/test-results.xml'
    testRunTitle: 'Python $(python.version)'

- task: PublishCodeCoverageResults@1
  displayName: 'Code Coverage'
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'

Solution: Problem was already discussed in other posts.解决方案:问题已经在其他帖子中讨论过了。 Amongst others Failed Cypress test exit in 'bash exited with code 1' in Azure DevOps Azure DevOps 中的“bash exited with code 1”中的 Cypress 测试退出失败

Adding ' ||添加'|| true' adressed it.真的'解决了它。 That is,那是,

pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml  || true

supresses the err抑制错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure Devops Pipeline 中运行 Python 代码并将输出导出到 Devops Repos ($(Build.SourcesDirectory)) 中的文件夹 - Run Python Code within Azure Devops Pipeline and Export output to folder in Devops Repos ($(Build.SourcesDirectory)) 将 Azure DevOps 管道详细信息发送到 SIEM - Send Azure DevOps Pipeline Details to SIEM 在 Azure Devops 发布管道中启动 Python 看门狗 - Launching a Python watchdog in an Azure Devops Release pipeline 如何在 azure devops 管道上进行 python 覆盖测试时引发错误? - How can i raising error while python coverage test on azure devops pipeline? Python Azure devOps Build Pipeline 中的突变测试报告 - Python Mutation testing reporting in Azure devOps Build Pipeline 在 Azure Devops 中运行管道期间下载任务附件 - Download Task attachment during a pipeline run in Azure Devops 在Azure Devops中为基于Python的Azure Function设置发布管道的正确方法 - Proper way to set up a release pipeline in Azure Devops for Python based Azure Function 推断错误:外部错误:*** 捕获未能执行:以代码 65 退出 - Infer Error: External Error: *** capture failed to execute: exited with code 65 python pdfkit 错误 wkhtmltopdf 以非零代码退出 -6 - python pdfkit error wkhtmltopdf exited with non-zero code -6 为什么我不能从 Azure DevOps 管道的发布阶段访问 Python 3.7.9? - why can't I access Python 3.7.9 from Release Stage of Azure DevOps pipeline?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM