[ERROR] [Sonar Gradle Plugin] Pipeline does not stop if Sonar failed (Version 6.0.0)

  • ALM used : Azure DevOps
  • CI system used : Azure DevOps
  • Scanner command used : gradlew sonar
  • Languages of the repository : java, gradle
  • Error observed : Build does not stop (Build successful), but sonar task failed!
  • Steps to reproduce : do gradlew sonar with new gradle plugin 6.0.0 version
  • Potential workaround : dont know, fix it? :slight_smile: *

Hi,

Welcome to the community!

Could you be more specific about this:

Do you mean that analysis completed successfully, but the project failed its Quality Gate? Or that analysis errored-out?

 
Ann

Use of preview features have been detected during analysis. Enable DEBUG mode to see them.

QUALITY GATE STATUS: FAILED - View details on SonarQube Cloud

[Incubating] Problems report is available at: file:///home/vsts/work/1/s/build/reports/problems/problems-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to Command-Line Interface Reference in the Gradle documentation.

BUILD SUCCESSFUL in 1m 22s

Hi,

I don’t find your list of analysis log warnings terribly helpful. Am I correct in thinking that you want your pipeline to fail when your Quality Gate fails?

The example in the docs includes this.

 
HTH,
Ann

Hi Ann,

that is principally correct, of course. But it has nothing to do with the pipeline itself, because it is a gradle task (which is platform independent). So my point is as mentioned before the command line gradle task is now not failing anymore if sonar is failing (which you can simply test with gradlew sonar on a project which failed and then you check the return code of the console)

I think this has something to do with that there is no error code correctly given back from sonar because of some structural change?

Best regards,
OBGIT Backend

Hi OBGIT Backend,

Uhm… Yes it does.

Analysis collects an analysis report bundle and submits that to the server. Then CI-side analysis ends. (Any error code at this point would indicate that no report had been submitted to the server.)

Server side, the analysis report is received, queued, and eventually popped from the queue and processed.

At the end of analysis report processing, the Quality Gate status is calculated. If you have paused your pipeline to wait for this event, then at that time, you may retrieve the Quality Gate status from the server, and act on it as needed.

 
HTH,
Ann

Ah I understand what you mean. Yeah that is correct but therefore we set the setting

property ‘sonar.qualitygate.wait’, true

which is as I undestand waiting for the retrieval.

Hi,

Since you’re using Azure DevOps, it’s slightly different for you. The docs will help.

 
Ann

Hi,

yes thank you for the link, but we also have shell scripts and jenkins which is doing the same

like

if ! ./gradlew clean build sonar; then
echo echo “Gradle task failed” >&2
read -n 1 -s -r -p “Press any key to continue”
fi

So am I correct that they have to also been adapted?

Hi,

Here are the Jenkins docs for that.

 
HTH,
Ann

Thx,

→ So we conclude there is no native gradle possibility to check at the console anymore :slight_smile:

I see the documentation “SonarScanner for Gradle | SonarQube Cloud Documentation” says now “Open the website to check”.
So I think the automatic checking is not possible anymore without CI things around it.

It was really simple via

“if ! ./gradlew clean build sonar; then” :frowning:

Hi. I’m getting the same issue: after upgrading to version 6.0.0 of gradle plugin, when the quality gate is not reached, Gradle job doesn’t fail (with 5.1.0.4882 version fails)

Configuration:

  • JDK 21
  • Gradle 8.11.1
  • Sonar Gradle Plugin version “6.0.0.5145”
  • Launched with -Dsonar.qualitygate.wait=true
  • Sonar server: paid SonarQube Cloud
No SonarArchitecture IR data present in directory "/builds/product/....."
QUALITY GATE STATUS: FAILED - View details on https://sonarcloud.io/dashboard?id=***.*******%3A******&branch=***********&resolved=false
[Incubating] Problems report is available at: file:///builds/product/****/*****************/src/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.11.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 3m 22s

Hello @sa-obgit-backend and @jerolba,

We are aware of the issue with the scanner incorrectly reporting analysis/quality gate failure, and we will be releasing a new version of the analyzer with the fix within the next 24 hours.

Cheers,

Dorian

2 Likes

Ah thank you, this is good to hear!

Hello again @sa-obgit-backend and @jerolba,

We released version 6.0.1.5171 of the scanner yesterday, which should address the issue. Please let us know if that version fixes the issues you encountered.

Cheers,

Dorian

1 Like

Hi Dorian,

yes, many thanks, it works like a charm.
the pipeline works again…

so from my side it is solved :slight_smile:

Best regards,
OBG-IT Backend

2 Likes

Hi Dorina.

Updated, tested, and fixed.

Thanks!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.