After upgrade SonarQube 10.4.1 my azure pipelines are failing on maven task

Following errors we are getting.

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project timatic-security-aggregator: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

Project Code: Java 11
Below is my Pipeline template

  • ${{ if eq(parameters.sonarEnable, ‘true’) }}:
    • task: SonarQubePrepare@6
      inputs:
      SonarQube: ${{ parameters.sonarQubeEndpoint }}
      scannerMode: ‘Other’
      extraProperties: |
      sonar.projectKey=${{ parameters.sonarProjectKey }}
      sonar.host.url=$(sonarHostURL)
      sonar.login=${{ parameters.sonarLogin }}
      sonar.coverage.jacoco.xmlReportPaths=${{ parameters.sonarCoverageJacocoXmlReportPaths }}
      sonar.exclusions= ${{ parameters.sonarExclusions }}
      sonar.java.source=11

    • task: Maven@3
      inputs:
      mavenPomFile: ‘pom.xml’
      goals: ${{ parameters.mavenGoal }}
      publishJUnitResults: true
      testResultsFiles: ‘**/surefire-reports/TEST-*.xml’
      javaHomeOption: ‘JDKVersion’
      jdkVersionOption: ‘1.11’
      mavenVersionOption: ‘Default’
      mavenOptions: ‘-Xmx3072m $(mavenOpts)’
      mavenAuthenticateFeed: true
      effectivePomSkip: false
      sonarQubeRunAnalysis: ${{ parameters.sonarEnable }}
      sqMavenPluginVersionChoice: ‘latest’
      checkStyleRunAnalysis: true
      pmdRunAnalysis: true

    • ${{ if eq(parameters.sonarEnable, ‘true’) }}:

      • task: SonarQubePublish@6
        inputs:
        pollingTimeoutSec: ‘600’
      • task: sonar-buildbreaker@8
        inputs:
        SonarQube: ${{ parameters.sonarQubeEndpoint }}

Welcome :slight_smile:

this means with Sonarqube 10.4.1, the Sonarqube analysis via Sonar Maven plugin needs to run with Java >= 17.
You may still analyze projects build with Java 8 …11, but / only the Sonarqube analysis must run with Java 17 or greater.

Gilbert

Should i update my pipeline template with jdkVersionOption: ‘1.17’ ??
any more changes ???

Sorry, don’t know much about Azure Devops.
AFAIK our pipelines set JAVA_HOME, i.e.

windows

  env:
    JAVA_HOME: $(JAVA_HOME_17_X64)
    PATH: $(JAVA_HOME_17_X64)/bin;$(PATH)

linux

  env:
    JAVA_HOME: $(JAVA_HOME_17_X64)
    PATH: $(JAVA_HOME_17_X64)/bin:$(PATH)

Just make sure that the Sonarqube analysis runs with Java 17.
In our Jenkins pipelines we use two mvn cli calls, the first for the build may use an older Java version - if needed - but the second one with sonar:sonar always runs with Java 17.

1 Like

after i updated my maven task like below and pipeline got success.

  • task: Maven@4
    inputs:
    mavenPomFile: ‘pom.xml’
    goals: ${{ parameters.mavenGoal }}
    publishJUnitResults: true
    testResultsFiles: ‘**/surefire-reports/TEST-*.xml’
    javaHomeOption: ‘JDKVersion’
    jdkVersionOption: ‘1.11’
    mavenVersionOption: ‘Default’
    mavenOptions: ‘-Xmx3072m $(mavenOpts)’
    mavenAuthenticateFeed: true
    effectivePomSkip: false
    sonarQubeRunAnalysis: false
    sqMavenPluginVersionChoice: ‘latest’
    checkStyleRunAnalysis: true
    pmdRunAnalysis: true

  • task: Maven@4
    inputs:
    mavenPomFile: ‘pom.xml’
    goals: ‘sonar:sonar’
    options: ‘-Dsonar.java.jdkHome=1.17’
    publishJUnitResults: true
    testResultsFiles: ‘**/surefire-reports/TEST-*.xml’
    javaHomeOption: ‘JDKVersion’
    jdkVersionOption: ‘1.17’
    mavenVersionOption: ‘Default’
    mavenOptions: ‘-Xmx3072m $(mavenOpts)’
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: ${{ parameters.sonarEnable }}
    sqMavenPluginVersionChoice: ‘latest’
    checkStyleRunAnalysis: true
    pmdRunAnalysis: true
    displayName: Sonar Analysis

1 Like