Please find Sonar Job Yaml file
Sonar_Cloud_Check:
stage: Test
image:
name: mcr.microsoft.com/dotnet/sdk:6.0
environment:
name: production
only:
variables:
- $ENV == "sonar"
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
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
allow_failure: true
script:
- apt-get update
- apt-get install --yes openjdk-17-jre
- dotnet tool install --global dotnet-sonarscanner
- export PATH=\"$PATH:$HOME/.dotnet/tools\"
- dotnet tool install --global coverlet.console
- export PATH="$PATH:$HOME/.dotnet/tools"
- cd /builds/UserManagementAPI
- dotnet restore
- dotnet sonarscanner begin /d:sonar.qualitygate.wait=true /k:"UM-FEandBE" /o:"group" /d:sonar.verbose=true /d:sonar.login="$SONAR_TOKEN" /d:"sonar.host.url=$SONAR_HOST_URL"
- dotnet build
- dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"
=========================================================
Error Logs:
BUG: GET 404 https://sonarcloud.io/api/project_branches/list?project=UM-FEandBE | time=285ms
14:06:44.778 DEBUG: Could not process project branches - continuing without it
14:06:44.778 INFO: Load project branches (done) | time=287ms
14:06:44.783 INFO: Check ALM binding of project 'UM-FEandBE'
14:06:45.077 DEBUG: GET 404 https://sonarcloud.io/api/alm_integration/is_project_bound?project=UM-FEandBE | time=293ms
14:06:45.078 INFO: Detected project binding: NONEXISTENT
14:06:45.079 INFO: Check ALM binding of project 'UM-FEandBE' (done) | time=296ms
14:06:45.081 INFO: Load project pull requests
14:06:45.363 DEBUG: GET 404 https://sonarcloud.io/api/project_pull_requests/list?project=UM-FEandBE | time=281ms
14:06:45.364 DEBUG: Could not process project pull requests - continuing without it
14:06:45.367 INFO: Load project pull requests (done) | time=285ms
14:06:45.372 INFO: Load branch configuration
14:06:45.383 INFO: Auto-configuring branch development
14:06:45.391 INFO: ------------------------------------------------------------------------
14:06:45.392 INFO: EXECUTION FAILURE
14:06:45.393 INFO: ------------------------------------------------------------------------
14:06:45.393 INFO: Total time: 9.635s
14:06:45.450 INFO: Final Memory: 9M/37M
14:06:45.450 INFO: ------------------------------------------------------------------------
14:06:45.450 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
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.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:127)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
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:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$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 interface org.sonar.scanner.scan.branch.BranchConfiguration
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.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
... 34 more
Caused by: Could not find a default branch for project with key 'UM-FEandBE'. Make sure project exists.
Process returned exit code 1
The SonarScanner did not complete successfully
14:06:45.796 Post-processing failed. Exit code: 1
section_end:1706018807:step_script
e[0Ksection_start:1706018807:cleanup_file_variables
e[0Ke[0Ke[36;1mCleaning up project directory and file based variablese[0;me[0;m
section_end:1706018807:cleanup_file_variables
e[0Ke[31;1mERROR: Job failed: exit code 1