azure-pipelinesazure-pipelines-tasks

##vso[task.complete result=Failed;] is not failing a script step


I thought that a call to ##vso[task.complete result=Failed;] should make the script step where it is called fail immediately but I have now seen one case in my pipeline where this is not the case.

Is my assumption wrong or there a bug in the Azure pipelines script task?

My build agent is running the task in an Ubuntu Container and the agent itself is a Linux agent.


Solution

  • I just made a small test and using below code leads to the desired goal of aborting the step with an error but showing only one error message in the Azure pipelines web ui:

    echo "##vso[task.logissue type=error]Something went very wrong."
    echo "##vso[task.complete result=Failed;]Make step fail"
    exit 0
    

    This is working fine but it looks really ugly since the "exit 0" gives the impression that the step is ok but actually the status will be "Failed" because of the task.complete call.

    Still I would like to know if this behaviour of the task.complete command to not abort the step is "by design" or I just found a workaround for a bug.