Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project : Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 7.9.1 (on a remote server)
    Sonar maven plugin 3.7.0.1746 (in my pom.xml file)
    Jenkins 2.222.1 (local server)
    Maven 3.6.0

  • what are you trying to achieve
    I want to perform an analysis with a Jenkins Pipeline with my remote server

  • what have you tried so far to achieve this
    I have succeed to do an analysis with my IDE (intelliJ) and it works with the command :
    $ mvn -B sonar:sonar. After that the server note the last analysis with the Quality Gate.
    Nevertheless, it does not work with my Jenkins Pipeline. I do not understand why it works with the IDE and not with Jenkins.

I have put on my pom.xml a <sonar.login> with a specific user token. This user has the right to perform an analysis on this particular project. I have also added the project key in the pom.xml. In my ~/.m2/settings.xml, I have put the <sonar.host.url>.
I also tried to set up manually a SonarQube server in Jenkins (in system configuration). I put there the url and my token thanks to a secret text but it does not work to.
I have also generated a Webhook but this is for the qualitygate variable in the pipeline and I don’t think it matters here.

I don’t know what to test now…
Any idea ?
Thanks

Hi,

Welcome to the community!

Would you post your code-formatted (``` on the line before and on the line after) analysis logs from Jenkins?

 
Ann

Thank you for your help. I have increased the output’s verbosity and I noticed that in my pipeline, Jenkins try to access SonarQube on localhost:9000 despite the fact that I told jenkins SonarQube was on a remote url with a specific token…
It is not the entire pipeline’s output but just the stage with the error.
Do I need to specify the url again in the pipeline ?

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (SonarQube check)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ mvn -B -e -X sonar:sonar
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0
Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: /home/alexis/Bureau/jdk1.8.0_241/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "5.3.0-46-generic", arch: "amd64", family: "unix"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.annotation.* < plexus.core
[DEBUG]   Imported: javax.annotation.security.* < plexus.core
[DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
[DEBUG]   Imported: javax.enterprise.util.* < plexus.core
[DEBUG]   Imported: javax.inject.* < plexus.core
[DEBUG]   Imported: org.apache.maven.* < plexus.core
[DEBUG]   Imported: org.apache.maven.artifact < plexus.core
[DEBUG]   Imported: org.apache.maven.classrealm < plexus.core
[DEBUG]   Imported: org.apache.maven.cli < plexus.core
[DEBUG]   Imported: org.apache.maven.configuration < plexus.core
[DEBUG]   Imported: org.apache.maven.exception < plexus.core
[DEBUG]   Imported: org.apache.maven.execution < plexus.core
[DEBUG]   Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG]   Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG]   Imported: org.apache.maven.model < plexus.core
[DEBUG]   Imported: org.apache.maven.monitor < plexus.core
[DEBUG]   Imported: org.apache.maven.plugin < plexus.core
[DEBUG]   Imported: org.apache.maven.profiles < plexus.core
[DEBUG]   Imported: org.apache.maven.project < plexus.core
[DEBUG]   Imported: org.apache.maven.reporting < plexus.core
[DEBUG]   Imported: org.apache.maven.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG]   Imported: org.apache.maven.settings < plexus.core
[DEBUG]   Imported: org.apache.maven.toolchain < plexus.core
[DEBUG]   Imported: org.apache.maven.usability < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG]   Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG]   Imported: org.codehaus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.* < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.component < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.container < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.context < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.* < plexus.core
[DEBUG]   Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG]   Imported: org.eclipse.aether.collection < plexus.core
[DEBUG]   Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG]   Imported: org.eclipse.aether.graph < plexus.core
[DEBUG]   Imported: org.eclipse.aether.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.installation < plexus.core
[DEBUG]   Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG]   Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG]   Imported: org.eclipse.aether.repository < plexus.core
[DEBUG]   Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG]   Imported: org.eclipse.aether.spi < plexus.core
[DEBUG]   Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG]   Imported: org.eclipse.aether.version < plexus.core
[DEBUG]   Imported: org.fusesource.jansi.* < plexus.core
[DEBUG]   Imported: org.slf4j.* < plexus.core
[DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
[DEBUG]   Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: plain
[DEBUG] Reading global settings from /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0/conf/settings.xml
[DEBUG] Reading user settings from /var/lib/jenkins/.m2/settings.xml
[DEBUG] Reading global toolchains from /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0/conf/toolchains.xml
[DEBUG] Reading user toolchains from /var/lib/jenkins/.m2/toolchains.xml
[DEBUG] Using local repository at /var/lib/jenkins/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /var/lib/jenkins/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project cidemo:cidemo-parent:pom:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project cidemo:commmon:jar:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project cidemo:jeu-prat:jar:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[DEBUG] Extension realms for project cidemo:todo-list:jar:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecycle mappings for packaging jar from ClassRealm[plexus.core, parent: null]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] CI Demo                                                            [pom]
[INFO] CI Demo :: Common                                                  [jar]
[INFO] CI Demo :: Jeu Prat                                                [jar]
[INFO] CI Demo :: Todo List                                               [jar]
[DEBUG] Resolving plugin prefix sonar from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix sonar to org.sonarsource.scanner.maven:sonar-maven-plugin from POM cidemo:cidemo-parent:pom:0.0.1-SNAPSHOT
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: cidemo:cidemo-parent:pom:0.0.1-SNAPSHOT
[DEBUG] Tasks:   [sonar:sonar]
[DEBUG] Style:   Aggregating
[DEBUG] =======================================================================
[INFO] 
[INFO] ------------------------< cidemo:cidemo-parent >------------------------
[INFO] Building CI Demo 0.0.1-SNAPSHOT                                    [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[DEBUG] Resolving plugin prefix sonar from [org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Resolved plugin prefix sonar to org.sonarsource.scanner.maven:sonar-maven-plugin from POM cidemo:cidemo-parent:pom:0.0.1-SNAPSHOT
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] === PROJECT BUILD PLAN ================================================
[DEBUG] Project:       cidemo:cidemo-parent:0.0.1-SNAPSHOT
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [test]
[DEBUG] Repositories (dependencies): [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Repositories (plugins)     : [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli)
[DEBUG] Style:         Aggregating
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <mojoExecution default-value="${mojoExecution}"/>
  <session default-value="${session}"/>
  <skip default-value="false">${sonar.skip}</skip>
</configuration>
[DEBUG] =======================================================================
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=50689, ConflictMarker.markTime=540783, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=33390, ConflictIdSorter.topsortTime=463128, ConflictIdSorter.conflictIdCount=0, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=1203510, ConflictResolver.conflictItemCount=0, DefaultDependencyCollector.collectTime=216796, DefaultDependencyCollector.transformTime=3649520}
[DEBUG] cidemo:cidemo-parent:pom:0.0.1-SNAPSHOT
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=8467, ConflictMarker.markTime=249067, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=3184, ConflictIdSorter.topsortTime=5496, ConflictIdSorter.conflictIdCount=0, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=12931, ConflictResolver.conflictItemCount=0, DefaultDependencyCollector.collectTime=4068, DefaultDependencyCollector.transformTime=294008}
[DEBUG] cidemo:commmon:jar:0.0.1-SNAPSHOT
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=589020, ConflictMarker.markTime=409785, ConflictMarker.nodeCount=6, ConflictIdSorter.graphTime=120908, ConflictIdSorter.topsortTime=29176, ConflictIdSorter.conflictIdCount=4, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=1447753, ConflictResolver.conflictItemCount=5, DefaultDependencyCollector.collectTime=12792896, DefaultDependencyCollector.transformTime=2613833}
[DEBUG] cidemo:jeu-prat:jar:0.0.1-SNAPSHOT
[DEBUG]    org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[DEBUG]       org.apiguardian:apiguardian-api:jar:1.1.0:test
[DEBUG]       org.opentest4j:opentest4j:jar:1.2.0:test
[DEBUG]       org.junit.platform:junit-platform-commons:jar:1.6.2:test
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=8012, ConflictMarker.markTime=248709, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=3219, ConflictIdSorter.topsortTime=5480, ConflictIdSorter.conflictIdCount=0, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=13404, ConflictResolver.conflictItemCount=0, DefaultDependencyCollector.collectTime=3758, DefaultDependencyCollector.transformTime=294723}
[DEBUG] cidemo:todo-list:jar:0.0.1-SNAPSHOT
[INFO] 
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ cidemo-parent ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=58264, ConflictMarker.markTime=277743, ConflictMarker.nodeCount=7, ConflictIdSorter.graphTime=42588, ConflictIdSorter.topsortTime=42800, ConflictIdSorter.conflictIdCount=6, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=893854, ConflictResolver.conflictItemCount=7, DefaultDependencyCollector.collectTime=92567830, DefaultDependencyCollector.transformTime=1454788}
[DEBUG] org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.7.0.1746:
[DEBUG]    org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile
[DEBUG]       org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:3.2.1:compile
[DEBUG]    org.sonarsource.scanner.api:sonar-scanner-api:jar:2.14.0.2002:compile
[DEBUG]    commons-lang:commons-lang:jar:2.6:compile
[DEBUG] Created new class realm plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746
[DEBUG] Importing foreign packages into class realm plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746
[DEBUG]   Included: org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.7.0.1746
[DEBUG]   Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4
[DEBUG]   Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.2.1
[DEBUG]   Included: org.sonarsource.scanner.api:sonar-scanner-api:jar:2.14.0.2002
[DEBUG]   Included: commons-lang:commons-lang:jar:2.6
[DEBUG] Configuring mojo org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar from plugin realm ClassRealm[plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746, parent: sun.misc.Launcher$AppClassLoader@7852e922]
[DEBUG] Configuring mojo 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar' with basic configurator -->
[DEBUG]   (f) mojoExecution = org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar {execution: default-cli}
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@5ab14cb9
[DEBUG]   (f) skip = false
[DEBUG] -- end configuration --
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] 09:51:47.334 keyStore is : 
[DEBUG] 09:51:47.339 keyStore type is : jks
[DEBUG] 09:51:47.340 keyStore provider is : 
[DEBUG] 09:51:47.340 init keystore
[DEBUG] 09:51:47.340 init keymanager of type SunX509
[DEBUG] 09:51:47.488 Create: /var/lib/jenkins/.sonar/cache
[INFO] 09:51:47.490 User cache: /var/lib/jenkins/.sonar/cache
[DEBUG] 09:51:47.490 Create: /var/lib/jenkins/.sonar/cache/_tmp
[DEBUG] 09:51:47.493 Extract sonar-scanner-api-batch in temp...
[DEBUG] 09:51:47.496 Get bootstrap index...
[DEBUG] 09:51:47.496 Download: http://localhost:9000/batch/index
[DEBUG] 09:51:47.610 Get bootstrap completed
[DEBUG] 09:51:47.619 Create isolated classloader...
[DEBUG] 09:51:47.623 Start temp cleaning...
[DEBUG] 09:51:47.628 Temp cleaning done
[DEBUG] 09:51:47.629 Execution getVersion
[INFO] 09:51:47.630 SonarQube version: 8.2.0
[INFO] 09:51:47.658 Default locale: "fr_FR", source code encoding: "UTF-8"
[DEBUG] 09:51:47.659 Work directory: /var/lib/jenkins/workspace/Pipe_Jeu_Alexis/target/sonar
[DEBUG] 09:51:47.660 Execution execute
[WARNING] 09:51:47.812 SonarScanner will require Java 11 to run starting in SonarQube 8.x
[DEBUG] 09:51:47.814 Community 8.2.0.32929
[INFO] 09:51:47.936 Load global settings
[DEBUG] 09:51:47.975 GET 401 http://localhost:9000/api/settings/values.protobuf | time=37ms
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for CI Demo 0.0.1-SNAPSHOT:
[INFO] 
[INFO] CI Demo ............................................ FAILURE [  1.174 s]
[INFO] CI Demo :: Common .................................. SKIPPED
[INFO] CI Demo :: Jeu Prat ................................ SKIPPED
[INFO] CI Demo :: Todo List ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.603 s
[INFO] Finished at: 2020-04-17T09:51:47+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project cidemo-parent: Unable to load component class org.sonar.scanner.bootstrap.ScannerPluginInstaller: Unable to load component class org.sonar.scanner.bootstrap.PluginFiles: Unable to load component class org.sonar.scanner.bootstrap.GlobalConfiguration: Unable to load component class org.sonar.scanner.bootstrap.GlobalServerSettings: Not authorized. Please check the properties sonar.login and sonar.password. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project cidemo-parent: Unable to load component class org.sonar.scanner.bootstrap.ScannerPluginInstaller
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
Caused by: org.sonar.api.utils.MessageException: Not authorized. Please check the properties sonar.login and sonar.password.
[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/MojoExecutionException
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Hi,

What does your pipeline look like?

 
Ann