"No analyses found in this build" for the Java project

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    9.9 LTS
  • how is SonarQube deployed: zip, Docker, Helm
    App Service
  • what are you trying to achieve
    Build Java project with Maven and post the results to the SonarQube. Have tried different options, but cannot get this one to work. Honestly, never done scans with Java projects.

This is the yaml configuration we have

trigger:
- main

pool:
  name: ***

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

- task: JavaToolInstaller@0
  inputs:
    versionSpec: '11'
    jdkArchitectureOption: 'x64'
    jdkSourceOption: 'PreInstalled'

- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'

- task: SonarQubeAnalyze@5
  inputs:
    jdkversion: 'JAVA_HOME_11_X64'

- task: SonarQubePublish@5
  inputs:
    pollingTimeoutSec: '300'

Results are:

##[warning]No analyses found in this build! Please check your build configuration.
Finishing: SonarQubePublish

Hey there.

Instead of adding this task:

- task: SonarQubeAnalyze@5
  inputs:
    jdkversion: 'JAVA_HOME_11_X64'

You should remove it and add this option to Maven@3

sonarQubeRunAnalysis: true

1 Like