配置VSTS以在发生错误时正确中止

问题描述 投票:0回答:1

给出以下.vsts-ci.yml文件

queue: Hosted Linux Preview

steps:
- script: |
    false
    true

预期的行为和实际行为不同。

预期的行为:在false命令中构建失败,true将不会被执行。

实际行为:构建成功,truefalse命令之后执行。

细节:

我希望VSTS构建在第一个命令false上失败。但是,VSTS也执行第二个命令true并报告成功。这意味着构建系统的shell设置不正确。正确的设置是设置pipefailerrexit。但似乎没有设置errexit,也可能没有设置pipefail

有没有办法在YAML文件中获得正确的行为,即pipefailerrexit,而不在脚本部分使用bash -c?我知道我可以通过将命令序列移动到shell脚本或Makefile来轻松解决,我只想知道是否有配置可能在shell中使用errexitpipefail设置获取YAML文件执行shell命令,最好是bash贝壳。

azure-devops azure-pipelines
1个回答
0
投票

似乎VSTS创建的bash shell没有设置pipefailerrexit标志。请参阅GitHub上的以下问题:https://github.com/Microsoft/vsts-agent/issues/1803

但是它们可以在YAML文件中设置,如下所示:

queue: Hosted Linux Preview

steps:
- script: |
    set -e ; set -o pipefail
    false
    true
© www.soinside.com 2019 - 2024. All rights reserved.