Getting this 401. I have checked and regenerated the token. It’s valid and being passed to the gitlab-ci.yaml script. No other config has changes (org or key for example). Everything worked fine for a month until yesterday. I did remove the original account owner and that seems to be the start of the issue. However like I mentioned I have swapped the token in gitlab and sonarcloud and verified the right token is showing up in the yaml file via - echo -n $SONAR_TOKEN | tail -c 3. Are there any other places an account owner may need to be swapped? The personal access token I used is associated to me and I am in the project owners group.
ALM used - Gitlab
CI system used - Gitlab
Scanner command used when applicable - sonar-scanner
Languages of the repository - javascript
Error observed
15:01:35.235 DEBUG: Execution execute
15:01:35.518 DEBUG: SonarCloud 9.16.0.560
15:01:35.761 INFO: Load global settings
15:01:36.390 DEBUG: GET 401 https://sonarcloud.io/api/settings/values.protobuf | time=626ms
15:01:36.399 INFO: ------------------------------------------------------------------------
15:01:36.399 INFO: EXECUTION FAILURE
15:01:36.400 INFO: ------------------------------------------------------------------------
15:01:36.400 INFO: Total time: 2.412s
15:01:36.436 INFO: Final Memory: 5M/20M
15:01:36.436 INFO: ------------------------------------------------------------------------
15:01:36.436 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.GlobalConfiguration
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.GlobalServerSettings
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
... 31 more
Caused by: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
Steps to reproduce - not sure
Potential workaround - none
gitlab-ci.yaml
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
sonar_cloud:
stage: sonar
needs:
- job: coverage
artifacts: true
before_script: []
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner -X
extends:
- .except_releases
Can I check, when you say that you removed the original owner, do you mean that you assigned yourself as the organization owner in SonarCloud? Other than this did you change any additional things in Gitlab?
It could also be useful to see the rest of the log, Redacted as necessary to see that there are no things occurring earlier in the process to cause this.
Thanks. I added myself to the owners group and I have a little Admin pill next to my name. I am an owner in gitlab as well. The only other thing I did was generate the new access token for myself and update it in the gitlab env vars.
Here’s the full log redacted:
Running with gitlab-runner 16.1.0~beta.59.g83c66823 (83c66823)
on blue-1.shared.runners-manager.gitlab.com/default xxx, system ID: xxx
feature flags: FF_USE_IMPROVED_URL_MASKING:true
Resolving secrets
00:00
Preparing the "docker+machine" executor
00:08
Using Docker executor with image sonarsource/sonar-scanner-cli:latest ...
Pulling docker image sonarsource/sonar-scanner-cli:latest ...
Using docker image sha256:1424be069637c176f86a8d27858b757a04e0853f4fdc7edb33b38226fc6457cb for sonarsource/sonar-scanner-cli:latest with digest sonarsource/sonar-scanner-cli@sha256:19a13915d563fa502b86cb654015da82d33074eaffa86fffb8864c86024f0301 ...
Preparing environment
00:04
Running on runnerName via runnerName...
Getting source from Git repository
00:06
Fetching changes...
Initialized empty Git repository in /builds/companyName/projectName/.git/
Created fresh repository.
Checking out xxx as detached HEAD (ref is refs/merge-requests/770/head)...
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
Restoring cache
00:26
Checking cache for sonar_cloud-non_protected...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/46150734/sonar_cloud-non_protected
Successfully extracted cache
Downloading artifacts
00:24
Downloading artifacts for coverage (xxx)...
Downloading artifacts from coordinator... ok host=storage.googleapis.com id=xxx responseStatus=200 OK token=xxx
Executing "step_script" stage of the job script
00:07
Using docker image sha256:1424be069637c176f86a8d27858b757a04e0853f4fdc7edb33b38226fc6457cb for sonarsource/sonar-scanner-cli:latest with digest sonarsource/sonar-scanner-cli@sha256:19a13915d563fa502b86cb654015da82d33074eaffa86fffb8864c86024f0301 ...
$ sonar-scanner
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /builds/companyName/projectName/sonar-project.properties
13:33:16.316 INFO: SonarScanner 4.8.0.2856
13:33:16.317 INFO: Java 11.0.19 Alpine (64-bit)
13:33:16.318 INFO: Linux 5.4.109+ amd64
13:33:16.474 DEBUG: keyStore is :
13:33:16.474 DEBUG: keyStore type is : pkcs12
13:33:16.474 DEBUG: keyStore provider is :
13:33:16.474 DEBUG: init keystore
13:33:16.474 DEBUG: init keymanager of type SunX509
13:33:16.611 DEBUG: Create: /builds/companyName/projectName/.sonar/cache
13:33:16.612 INFO: User cache: /builds/companyName/projectName/.sonar/cache
13:33:16.613 DEBUG: Create: /builds/companyName/projectName/.sonar/cache/_tmp
13:33:16.615 DEBUG: Extract sonar-scanner-api-batch in temp...
13:33:16.619 DEBUG: Get bootstrap index...
13:33:16.619 DEBUG: Download: https://sonarcloud.io/batch/index
13:33:17.312 DEBUG: Get bootstrap completed
13:33:17.320 DEBUG: Download https://sonarcloud.io/batch/file?name=scanner-sonarcloud-8.0.0.43389-all.jar to /builds/companyName/projectName/.sonar/cache/_tmp/fileName.tmp
13:33:20.538 DEBUG: Create isolated classloader...
13:33:20.550 DEBUG: Start temp cleaning...
13:33:20.553 DEBUG: Temp cleaning done
13:33:20.554 DEBUG: Execution getVersion
13:33:20.582 INFO: Analyzing on SonarQube server 8.0.0.43389
13:33:20.583 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
13:33:20.583 DEBUG: Work directory: /builds/companyName/projectName/.scannerwork
13:33:20.585 DEBUG: Execution execute
13:33:20.880 DEBUG: SonarCloud 9.16.0.560
13:33:21.076 INFO: Load global settings
13:33:21.650 DEBUG: GET 401 https://sonarcloud.io/api/settings/values.protobuf | time=572ms
13:33:21.657 INFO: ------------------------------------------------------------------------
13:33:21.657 INFO: EXECUTION FAILURE
13:33:21.657 INFO: ------------------------------------------------------------------------
13:33:21.657 INFO: Total time: 5.381s
13:33:21.674 INFO: Final Memory: 5M/24M
13:33:21.674 INFO: ------------------------------------------------------------------------
13:33:21.675 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.GlobalConfiguration
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.GlobalServerSettings
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
... 31 more
Caused by: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
13:33:21.679 ERROR:
13:33:21.679 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
I’m not sure of a specific reason that might cause this behavior from the logs, however, it could be worth checking if your organization has a specific permission template or permission assignment that is potentially limiting your user but was working with the previous user. It could be that you need to assign yourself to this template.
These settings can be found in the Organization Administration section.
It seemed to be some kind of token mismatch. I was using a token generated in gitlab with the right permissions and the sonar UI told me it was good when I updated my org settings with that token. But when I deleted and recreated the account because nothing else was working I was given a token by sonar in the creation process and everything worked when I set that in my gitlab env vars and didn’t use a gitlab generated token. Would have been nice if the docs/UI were more clear about what tokens should come from where.
I’m sorry for the issue here, I understand that this caused confusion. I will raise an issue with the documents team to see if we can improve the documentation with this information. I’m glad to hear that you are no longer affected by the issue.