使用命令行将 Azure DevOps 构建标记为失败.
在 Azure DevOps 中, 您可以使用命令行界面 (命令行界面) 管理和自动化您的构建管道. 有时, 您可能想使用 CLI 将构建标记为失败.
To mark a build as failed using the Azure DevOps 命令行界面, 你可以使用以下命令:
az pipelines runs update --id <run-id> --state Failed
在这个命令中, <run-id>
是您想要标记为失败的构建运行的 ID. You can find the run ID by navigating to the build summary page in the Azure DevOps portal.
运行命令后, the build will be marked as failed and any subsequent tasks in the build pipeline will be skipped.
您还可以通过添加失败原因来添加 --reason
范围, 像这样:
az pipelines runs update --id <run-id> --state Failed --reason "Build failed due to errors in script"
在这个例子中, 失败的原因是 “由于脚本错误,构建失败”. This message will be displayed in the build summary page in the Azure 开发运营 portal.
综上所述, 使用 Azure DevOps CLI, 您只需使用几个简单的命令即可将构建标记为失败. 当您需要手动触发构建失败或者构建管道中存在您想要突出显示的错误时,这非常有用.