No result shown on SonarQube

I’m using the latest version of SonarQube Community on my Ubuntu machine.
I’m trying to integrate it with azure DevOps pipelines for an android application (Gradle).

- develop

  name: name_of_my_pool

- task: SonarQubePrepare@5
    SonarQube: 'name_of_the_project'
    scannerMode: 'Other'
    extraProperties: |
      # Additional properties that will be passed to the scanner,
      # Put one key=value per line, example:
      # sonar.exclusions=**/*.bin

- script: |
    java -version
    wget -O JAVA_HOME_17_X64.tar.gz
  displayName: Download JDK17

- task: JavaToolInstaller@0
    versionSpec: '17'
    jdkArchitectureOption: 'x64'
    jdkSourceOption: 'LocalDirectory'
    jdkFile: 'JAVA_HOME_17_X64.tar.gz'
    jdkDestinationDirectory: '$(Agent.ToolsDirectory)/JAVA_HOME_17/X64'
    cleanDestinationDirectory: true
    createExtractDirectory: false

- script: |
    java -version
    echo Environment Variable JAVA_HOME_17_X64 is $(JAVA_HOME_17_X64)
    tree $(Agent.ToolsDirectory)
  displayName: Check JDK version

- task: Gradle@3
    gradleWrapperFile: '$(Build.Repository.LocalPath)/gradlew'
    workingDirectory: '$(Build.Repository.LocalPath)'
    tasks: 'build'
    publishJUnitResults: true
    testResultsFiles: '**/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.17'
    gradleOptions: '-Xmx3072m'
    sonarQubeRunAnalysis: true
    sqGradlePluginVersionChoice: 'specify'
    sonarQubeGradlePluginVersion: '2.6.1'
    spotBugsAnalysis: false
- task: SonarQubePublish@5
  condition: always()
    pollingTimeoutSec: '300'

Although during the build, SonarQube analysis is enabled, but during SonarQube Publish I receive this warning: No analyses found in this build! Please check your build configuration.

This is extremely old. Can you try using the latest version?

I did that, but it outputted the same warning.
The previous task always fails, could that be the reason?

If the task is the Gradle build… yes! That sounds like SonarQube analysis could be failing, which means an analysis never gets sent to SonarQube (and there’s no quality gate to be found).

What is the step failing with? What error message?

Gradle@3 is always failing.
Gradle task.txt (1.2 MB)

I added the condition always() in SonarqubePublish@5 task just in case but it doesn’t seem to show any difference

Well it looks like you have failing tests.

2024-04-24T08:54:24.3889639Z 10 tests completed, 8 failed, 1 skipped
2024-04-24T08:54:24.7886111Z > Task :libraries:mediaupload:impl:testDebugUnitTest FAILED
2024-04-24T08:54:28.0897546Z > Task :app:packageFdroidDebug
2024-04-24T08:54:28.0897952Z > Task :app:createFdroidDebugApkListingFileRedirect
2024-04-24T08:54:29.8883550Z > Task :app:packageGplayDebug
2024-04-24T08:54:29.8884209Z > Task :app:createGplayDebugApkListingFileRedirect
2024-04-24T08:54:30.0883813Z > Task :libraries:deeplink:lintAnalyzeDebug
2024-04-24T08:54:35.8884235Z FAILURE: Build failed with an exception.
2024-04-24T08:54:35.8884609Z * What went wrong:
2024-04-24T08:54:35.8885597Z Execution failed for task ':libraries:mediaupload:impl:testDebugUnitTest'.

A problem you would have whether or not SonarQube analysis was running.

You need to fix those tests, or skip those tests, or make sure that the build continues when tests fail (not recommended)

The analysis runs after your (hopefully successful) build.

how can I skip those tests or make sure that the build continues when tests fail

You’ll need to refer to Gradle’s documentation. SonarQube just needs a working build. :slight_smile:

i have changed the pipeline to build on a specific subproject just for try
pipeline.txt (1.8 KB)

but i still receive the same warning despite of the execution success

Well, you’ve set “run analysis” to false

sonarQubeRunAnalysis: false

so I’m not surprised