Template for a good new topic, formatted with Markdown:
- ALM used (Azure DevOps)
- CI system used ( Azure DevOps)
- Scanner command used:
name: DEVBUILD
demands: maven
steps:
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean compile package install -P=DEV -DskipTests=true'
publishJUnitResults: false
javaHomeOption: 'Path'
jdkDirectory: 'C:\Program Files\Amazon Corretto\jdk1.8.0_332'
mavenVersionOption: 'Path'
mavenDirectory: 'D:\build_resources\Maven'
mavenSetM2Home: true
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- task: PowerShell@2
displayName: 'Run sonar:sonar'
inputs:
targetType: 'inline'
script: |
mvn sonar:sonar```
Error: ```[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project TechPubViewer: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.9.1.2184
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
[ERROR] urls[1] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
[ERROR] urls[5] = file:/C:/Windows/ServiceProfiles/NetworkService/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
##[error]PowerShell exited with code '1'.
I’ve also tried using the azure devops plugins ‘sonarqube prepare’. I’ve searched through forum and I see few solutions like separating it into 2 tasks and changing the java version right after the build task. The issue I’m having is, I build the project with Java 8 and then I run the mvn sonar:sonar
which should run using the Java 11 (because that’s the default JAVA_HOME) for my agent but it does not. I’m also very confused as to why it’s compiling the code again as it should only be doing analysis. When I ran the command on this agent itself, after compiling the project, the command mvn sonar:sonar
tries to compile the project again in Java 11 and fails. Any help here would be greatly appreciated.