Carlos Mario
Carlos Mario

Reputation: 159

Wait for sonar qube quality gate on Azure DevOps

I'm creating a pipeline as code using a YAML file on Azure DevOps, but i have a 'little' stoper; i don't know how to break the build when quality gates fail, on jenkins that option is as easy as this:

stage("Quality Gate") {
        steps {
          timeout(time: 1, unit: 'HOURS') {
            waitForQualityGate abortPipeline: true
          }
     }
 }

But, how to do the same but on Azure DevOps using YAML?

Thank you so much.

Upvotes: 0

Views: 2064

Answers (2)

Carlos Mario
Carlos Mario

Reputation: 159

Hello developers and devops

I have created a little BashScript to break the builds when sonar quality gates fail, this work with any language and any build tool and any CI server https://github.com/carlosdeveloper10/wait-for-sonar-qg

Upvotes: 1

Jayendran
Jayendran

Reputation: 10930

You can try the UI way of creating build pipeline to learn more Yaml commands

For an instance,

From the below UI, control options helps you to define the condition to success or fail the build


Condition : Only when all previous taks have succeeded

enter image description here

The corresponding yaml for this would be

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'

Condition : Even if a previous task has failed. unless the build was canceled

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'

  condition: succeededOrFailed()

Condition : Even if a previous task has failed. even if the build was canceled

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'

  condition: always()

Like this you can find all the yaml commands (or) Syntax using the UI way of building pipeline

You can able to convert the UI -> Yaml by using below way

enter image description here

Upvotes: 1

Related Questions