Nuz
Nuz

Reputation: 85

Azure Devops pipeline finish with warning badge when a job failed

I have a pipeline (Azure Devops yaml) with some jobs. They run in parallel. But when one fails, the build ends with a warning and not an error badge. Why? I expected the pipeline to end in error.

enter image description here

Edit: pipelines.yml

pool:
  name: Default


jobs:
- job: FirstJob
  steps:
  - script: echo First!

- template: template.yml
  parameters:
     name: Second

- template: template.yml
  parameters:
     name: Third

- template: template.yml
  parameters:
     name: Fourth

- template: template.yml
  parameters:
     name: Fifth

- template: template.yml
  parameters:
     name: Sixth

- template: template.yml
  parameters:
     name: Seventh

template.yml:

parameters:
  - name: name
    type: string
    default: -- 

jobs:
- job: ${{ parameters.name }}
  dependsOn: FirstJob
  continueOnError: true
  variables:
      BuildTag: ${{ parameters.name }}

  steps:
    - task : AddTag@0
      inputs:
        tags: '$(BuildTag)'

    - task: DotNetCoreCLI@2
      inputs:
        command: 'build'
        projects: 'foo'
      condition: and(succeeded(), eq(variables['BuildTag'], 'Sixth'))

I see my mistake with continueOnError: true.

Upvotes: 6

Views: 18729

Answers (2)

macherif
macherif

Reputation: 348

Maybe u need to uncheck "advanced" => "FAIL ON STDERR" (If this option is selected, the build will fail when the remote commands or script write to STDERR).

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76996

Azure Devops pipeline finish with warning badge when a job failed

Thanks for your comments and sample, which make me found out the reason for this issue:

The property continueOnError. This behavior is by designed and is not a bug. There is no way to fix it at present.

If we set the continueOnError: true, which will make the future jobs should run even if this job fails. In order to achieve it, Azure Devops will use a "deceptive way" to treat error as warning, so that the error will not prevent the building. That the reason why the job failed, but the pipeline show it as warning.

We could even just reproduce this issue with Control Options Continue on error in non-YAML task:

enter image description here

enter image description here

Besides, it does not affect the completion of the PR.

To resolve this issue, you could comment it in the YAML. If it is necessary for you, you could set the condition: always() for the future jobs:

jobs:
- job: ${{ parameters.name }}
  dependsOn: FirstJob
  variables:
      BuildTag: ${{ parameters.name }}

  steps:
   ...

- job: Second
  condition: always()

- job: Third
  condition: always()

Hope this helps.

Upvotes: 11

Related Questions