Azure DevOps – Tips and Tricks – 4 – How to use ContinueOnError to Continue when the Task is failing

In this article, we are going to learn about a simple tip on how to continue the Pipeline execution even when a non-critical Task is failing for some reason.

Advertisements

Introduction

Sometimes, you many have some Pipeline Tasks which may be dependent on third party APIs on which you wouldn’t have much control. In these scenarios, if the Task is failing (or may be 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 would get fixed. May be, invoking the third party API might not be very important for your upcoming release.

Advertisements

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 ContinueOnError property.

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

Azure DevOps – Tips and Tricks – 4 – How to use ContinueOnError to Continue when the Task is failing-Pipeline

As shown in the above screenshot, the following points 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 bee added to ignore if there any errors while executing the pipeline.
Advertisements

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.

Azure DevOps – Tips and Tricks – 4 – How to use ContinueOnError to Continue when the Task is failing – Pipeline Execution
Advertisements

Summary:

In this blob post, we have learnt how to continue the execution of the pipeline inspite-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.

Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups

WhatsApp

Telegram

Advertisements
Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s