Marking Azure DevOps Builds as Failed Using Command Line.
In Azure DevOps, you can use the command-line interface (CLI) to manage and automate your build pipeline. Sometimes, you may want to mark a build as failed using the CLI.
To mark a build as failed using the Azure DevOps CLI, you can use the following command:
az pipelines runs update --id <run-id> --state Failed
In this command, <run-id>
is the ID of the build run that you want to mark as failed. You can find the run ID by navigating to the build summary page in the Azure DevOps portal.
Once you’ve run the command, the build will be marked as failed and any subsequent tasks in the build pipeline will be skipped.
You can also add a reason for the failure by including the --reason
parameter, like this:
az pipelines runs update --id <run-id> --state Failed --reason "Build failed due to errors in script"
W tym przykładzie, the reason for the failure is “Build failed due to errors in script”. This message will be displayed in the build summary page in the Azure DevOps portal.
In conclusion, using the Azure DevOps CLI, you can mark a build as failed with just a few simple commands. This can be useful in cases where you need to manually trigger a build failure or if there are errors in the build pipeline that you want to highlight.