Sonarqube commnuity edition 9.7.1.62043
Azure Devops Server 2020
Sonar Qube installed on same server as Azure DevOps server.
We have CI pipeline to scan the source code which fails with following error,
we tried using SOnarqube taks integrated with Maven Build, Kept it seperately, Ran as a Command line
Error:
[ERROR] No plugin found for prefix 'sonar' in the current project and in the plugin groups [org.sonarsource.scanner.maven, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (D:\Program Files\apache-maven-3.8.6\local_repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'sonar' in the current project and in the plugin groups [org.sonarsource.scanner.maven, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (D:\Program Files\apache-maven-3.8.6\local_repository), central (https://repo.maven.apache.org/maven2)]
at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve (DefaultPluginPrefixResolver.java:95)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix (MojoDescriptorCreator.java:266)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor (MojoDescriptorCreator.java:220)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments (DefaultLifecycleTaskSegmentCalculator.java:104)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments (DefaultLifecycleTaskSegmentCalculator.java:83)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:89)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[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/NoPluginFoundForPrefixException
I tried using the sonarqube inbuilt task in Azure Devops server Pipeline Eg: Prepare analysis → Maven Build with Run Analyse → Publish result
Also tried with the command,
mvn clean verify sonar:sonar \ -Dsonar.projectKey=*********** \ -Dsonar.host.url=http://localhost:9000 \ -Dsonar.login=*********
Now the error is [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project ips-parent-pom: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property. → [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] MojoExecutionException - Apache Maven - Apache Software Foundation
The process ‘D:\Program Files\apache-maven-3.8.6\bin\mvn.cmd’ failed with exit code 1
Could not retrieve code analysis results - Maven run failed.
##[error]Build failed.
Finishing: Maven
Sonar Prepare → Maven Build → mvn sonar:Sonar cmd → Sonar Publish is the current sequence.
Now SonarPublish task fails:
2022-11-23T13:20:37.8340014Z ##[section]Starting: SonarQubePublish
2022-11-23T13:20:37.8432707Z ==============================================================================
2022-11-23T13:20:37.8433161Z Task : Publish Quality Gate Result
2022-11-23T13:20:37.8433547Z Description : Publish SonarQube’s Quality Gate result on the Azure DevOps build result, to be used after the actual analysis.
2022-11-23T13:20:37.8433880Z Version : 5.0.2
2022-11-23T13:20:37.8434051Z Author : sonarsource
2022-11-23T13:20:37.8434417Z Help : Version: 5.0.2. More Information
2022-11-23T13:20:37.8434833Z ==============================================================================
2022-11-23T13:20:42.0543437Z ##[error][SQ] Could not fetch metrics
2022-11-23T13:20:42.0553139Z ##[error][SQ] API GET ‘/api/metrics/search’ failed, status code was: 401
2022-11-23T13:20:42.0845327Z ##[error][SQ] API GET ‘/api/ce/task’ failed, status code was: 401
2022-11-23T13:20:42.0848362Z ##[error][SQ] Could not fetch task for ID ‘AYSkpaHX0p_LhsqajdVH’
2022-11-23T13:20:42.0926665Z ##[section]Finishing: SonarQubePublish