How to Use ContinueOnError in Azure DevOps for Task Failure

Introduction

Sometimes, you may have some Pipeline Tasks that may be dependent on third-party APIs on which you wouldn’t have much control. In these scenarios, if the Task is failing (or maybe failing intermittently) due to a load/bug in the third-party API, your entire pipeline would fail. You don’t have any insights about when the bug will get fixed. Maybe, invoking the third-party API might not be very important for your upcoming release.

Solution

In this case, it absolutely makes sense to continue the execution of the next set of Tasks. In this article, we are going to learn how to continue the execution of the pipeline if a particular Task has failed by using the ContinueOnError property.

Let’s build a pipeline with a few tasks where we simulate an error in one of the tasks, as shown below.

Jobs

As shown in the above screenshot, the following points are to be noted.

  • The task named Not So Important Task, an intentional typo (instead of Write-Host, I used Write-Hosts) has been introduced to simulate an error.
  • An attribute called continueOnError has been added to ignore if there are any errors while executing the pipeline.

Now, when you run the pipeline, an indication about the error for the Task is shown and the execution will carry forward as shown below.

Jobs in run

Summary

In this blog post, we have learnt how to continue the execution of the pipeline in spite of having an error in one of the tasks. This simple technique can be used in scenarios where you have a non-mandatory task that's failing intermittently and you want to continue the execution of the pipeline.

Feel free to comment in the below section if you have any questions. Thanks for reading.


Similar Articles