QUALITY GATE STATUS: FAILED when branch does not exist


We’re experiencing QUALITY GATE STATUS: FAILED error when running an analysis on a new branch on Sonar Cloud. The analysis run should create the branch and publish the result, this is not happening.
The first failed run actually creates the branch with no analysis run inside, re-executing the pipeline leads to a successful result since, after the first execution, the branch exists.

There is no actual way to create the branch before analysis using Rest APIs or similar from the pipeline, what should we do to avoid pipeline re-execution when a given branch does not still exist?

ALM used:
Azure DevOps

CI system used:
Azure DevOps

Scanner command used in Pipeline:

- task: SonarCloudPrepare@1
  displayName: Initialize Sonar Cloud Analysis
    SonarCloud: 'Sonar Cloud Name'
    organization: 'orgname'
    scannerMode: 'Other'
    extraProperties: |

- task: Maven@4
    mavenPomFile: 'pom.xml'
    goals: 'clean install'
    options: '--settings settings.xml'
    publishJUnitResults: false
    javaHomeOption: 'Path'
    jdkDirectory: '/usr/lib/jvm/java-21-amazon-corretto'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: true
    sqMavenPluginVersionChoice: 'latest'

- task: SonarCloudPublish@1
  displayName: Publish Sonar Cloud Result
    pollingTimeoutSec: '300'

Languages of the repository:
Java (Maven)

Error observed:
When the branch my_branch does not exist on the Sonar Cloud Project, the execution of the above steps results in branch creation and Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project demo: QUALITY GATE STATUS: FAILED is thrown. Subsequent executions will be successful.

Steps to reproduce:

  1. Delete my_branch branch from Sonar Cloud project
  2. Run analysis
1 Like


Welcome to the community!

What’s the project-level default for the New Code Definition? Is it using a reference branch (e.g. main) or some other reference point?

What do you see in the SonarCloud UI when a branch is in this state? I’m wondering if the Quality Gate status is actually “Not Computed”, and that’s being returned (wrongly, obvs) as FAILED by this particular call.


Hi Ann,

Thanks for your welcome and your reply :smiley:!

Currently, the New Code Definition is based on Previous version. The UI states “Any code that has changed since the previous version is considered new code.Recommended for projects following regular versions or releases”.

The status of the branch in this situation is “none”. The branch appears as not analyzed yet and the analysis is in error.

Thank you,


Could you share a screenshot of this?


Hi Ann,

Forgive me for my delay. Here’s the screenshot you asked:

When clicking on it (in the screenshot is the develop branch):

Thanks in advance,


Thanks for the screenshots.

What I see is an analysis with 0 issues, not an unanalyzed state.

And at this point, I’m going to flag this for more expert eyes for this part:


1 Like

Hi @francescom412 ,

I guess you are using the property sonar.qualitygate.wait=true to make your CI pipeline fails in case of a red quality gate.

I was able to reproduce that on the first analysis of a branch, the quality gate is not computed, and so the status is “NONE” in the UI. We are considering this a reason to fail the scanner, to detect a later misconfiguration of the quality gate or clean code period.
I agree this is not a great user experience for the first analysis of a new branch.

I have created a ticket, but I am not sure when it will be tackled.

In the meantime, I suggest you remove the sonar.qualitygate.wait=true for the first analysis and only add it a bit later, when your branch already has some successful analyses.

1 Like

Hi Julien,

Thanks a lot, for the moment we implemented a retry strategy as we do not want in any case to deploy something that has not passed the Quality Gate.

Waiting for updates on the new ticket,
Thanks again for your support,