Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continue Azure Pipeline on failed task

I have a task that runs Cypress:

-ErrorAction SilentlyContinue
cd $(System.DefaultWorkingDirectory)/_ClientWeb-Build-CI/ShellArtifact/
npx cypress run

And I've set the ErrorActionPreference to continue. But when my Cypress fails:

##[error]PowerShell exited with code '1'.

The next task is canceled and the release failed. How do I continue the release even Cypress failed, and is it possible to give a boolean a true/false value based on the Cypress task result?

like image 248
Peter Boomsma Avatar asked Jul 07 '19 20:07

Peter Boomsma


People also ask

How do you rerun a pipeline in Azure?

If you click on your stage box on the main pipeline window, you will see an up and down arrow. Click on this to expand the stage and then there is a button to re-run the stage. You could always grab the requests it sends (f12) if you need to do this programatically.

What happens when pipeline is paused?

However, if you pause a running Stream pipeline job, the current state of the job is saved and the job is gracefully stopped at that point. When the resume command is issued, a new job is started to restart the Pipeline Version from the previously saved state.

Is Microsoft phasing out Azure DevOps?

PRO TIP: No, Azure DevOps is not being deprecated. Second, Microsoft is introducing a new tool called Azure Automation. Azure Automation is a machine learning platform that can automate the deployment of applications and services. Azure Automation is similar to Azure DevOps Services, but it is not a preview program.


2 Answers

If you want to continue the release even the Cypress task failed, just add to the Cypress task this line:

continueOnError: true 
like image 77
Shayki Abramczyk Avatar answered Sep 19 '22 12:09

Shayki Abramczyk


you can put a condition on the subsequent tasks to work even if previous tasks failed.

jobs:
- job: Foo

  steps:
  - powershell: |
      your code here
  - script: echo Hello!
    condition: always() # this step will always run, even if the pipeline is cancelled

- job: Bar
  dependsOn: Foo
  condition: failed() # this job will only run if Foo fails

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#job-status-functions
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml

like image 42
4c74356b41 Avatar answered Sep 19 '22 12:09

4c74356b41