简体   繁体   中英

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.

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

在此处输入图片说明

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

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM