To utilize the curl result in order to cause the Azure Pipelines task to fail, you can use the exit command in a script task.
For example, if you are running a curl command in a script task and you want the task to fail if the curl command returns a non-zero exit code, you could use the following script:
curl <your curl command here>
if [ $? -ne 0 ]; then
echo "Curl command failed"
exit 1
fi
This script will run the curl command and then check the exit code using the $?
variable. If the exit code is not equal to 0 (indicating an error), the script will print an error message and then use the exit 1
command to fail the entire task.
Asked: 2021-05-08 11:00:00 +0000
Seen: 11 times
Last updated: Jan 12 '22