Reputation: 1330
when i use this config in azure devops to scan my project in SonarCloud with a pipeline.
- task: SonarCloudPrepare@1
displayName: Sonar cloud prepare
inputs:
SonarCloud: 'SonarCloud'
organization: 'gt'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'gt-acf-front'
cliProjectName: 'gt-acf-front'
cliSources: 'src/'
extraProperties: |
sonar.inclusions=**/*
sonar.scm.disabled=true
- task: SonarCloudAnalyze@1
displayName: Sonar analyze
- task: SonarCloudPublish@1
displayName: Publish quality gate Result
inputs:
pollingTimeoutSec: '300'
it works well **************
but when i change to the new version of tasks :
i have this error :
##[debug]Evaluating condition for step: 'Sonar analyze'
##[debug]Evaluating: SucceededNode()
##[debug]Evaluating SucceededNode:
##[debug]=> True
##[debug]Result: True
##[section]Starting: Sonar analyze
==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarCloud server.
Version : 2.3.2
Author : sonarsource
Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
##[debug]Resource Utilization warnings is disabled, switch "DISABLE_RESOURCE_UTILIZATION_WARNINGS" variable to "true" if you want to enable it
##[debug]Using node path: /azp/externals/node16/bin/node
##[debug]agent.TempDirectory=/azp/_work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_JDKVERSION
##[debug]loading INPUT_SONARSCANNERARGS
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SONAR_ENDPOINT
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 7
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]check path : /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/lib.json
##[debug]adding resource file: /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/lib.json
##[debug]system.culture=en-US
##[debug]jdkversion=JAVA_HOME_17_X64
##[debug]SONAR_SCANNER_MODE=CLI
##[debug]SONAR_SERVER_VERSION=8.0.0
##[debug]JAVA_HOME_17_X64=/usr/lib/jvm/java-17-openjdk
##[debug]JAVA_HOME_17_X64 was found with value /usr/lib/jvm/java-17-openjdk, will switch to it for Sonar scanner...
##[debug]JAVA_HOME=undefined
##[debug]set JAVA_HOME=/usr/lib/jvm/java-17-openjdk
##[debug]Processed: ##vso[task.setvariable variable=JAVA_HOME;isOutput=false;issecret=false;]/usr/lib/jvm/java-17-openjdk
##[debug]SONAR_SCANNER_MODE=CLI
##[debug]SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io","sonar.token":***,"sonar.organization":"gt","sonar.projectKey":"GT_gt-acf-front","sonar.projectName":"gt-front","sonar.projectVersion":"1.0","sonar.sources":"/azp/_work/7/s/src/","sonar.branch.name":"test","sonar.scanner.metadataFilePath":"/azp/_work/_temp/sonar/2658/ae4df0d0-f5da-ae03-d449-32580152754d/report-task.txt","sonar.inclusions":"**/*","sonar.scm.disabled":"true"}
##[debug]SONAR_SCANNER_LOCATION=
##[debug]Absolute path for pathSegments: /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2,sonar-scanner,bin,sonar-scanner = /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner
##[debug]Using scanner at /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner
##[debug]which '/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner'
##[debug]found: '/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner'
##[debug]system.debug=true
##[debug]/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner arg: -X
##[debug]exec tool: /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner
##[debug]arguments:
##[debug] -X
[command]/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner -X
WARN Ignoring property 'sonar.token' from env variable 'SONARQUBE_SCANNER_PARAMS' because it is already defined
INFO Scanner configuration file: /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/conf/sonar-scanner.properties
WARN Ignoring property 'sonar.token' from env variable 'SONARQUBE_SCANNER_PARAMS' because it is already defined
INFO Project root configuration file: NONE
WARN Ignoring property 'sonar.token' from env variable 'SONARQUBE_SCANNER_PARAMS' because it is already defined
INFO SonarScanner CLI 6.1.0.4477
INFO Java 17.0.12 Alpine (64-bit)
INFO Linux 5.4.0-192-generic amd64
DEBUG Scanner max available memory: 3 GB
DEBUG uname -m returned 'x86_64'
DEBUG Create: /root/.sonar/cache
INFO User cache: /root/.sonar/cache
DEBUG Create: /root/.sonar/cache/_tmp
Loaded [441] system trusted certificates
INFO JRE provisioning: os[alpine], arch[x86_64]
DEBUG --> GET https://api.sonarcloud.io/analysis/jres?os=alpine&arch=x86_64
DEBUG <-- 403 https://api.sonarcloud.io/analysis/jres?os=alpine&arch=x86_64 (437ms, 82-byte body)
INFO EXECUTION FAILURE
INFO Total time: 1.062s
2024-08-21T12:19:09.0022188Z ##[error]12:19:08.996 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Error status returned by url [https://api.sonarcloud.io/analysis/jres?os=alpine&arch=x86_64]: 403
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182)
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callApi(ServerConnection.java:145)
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callRestApi(ServerConnection.java:123)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreMetadata(JavaRunnerFactory.java:159)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreFromServer(JavaRunnerFactory.java:138)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.createRunner(JavaRunnerFactory.java:85)
at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:53)
at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:118)
at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:63)
2024-08-21T12:19:09.0032048Z ##[debug]Processed: ##vso[task.logissue type=error;]12:19:08.996 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Error status returned by url [https://api.sonarcloud.io/analysis/jres?os=alpine&arch=x86_64]: 403
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182)
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callApi(ServerConnection.java:145)
at org.sonarsource.scanner.lib.internal.http.ServerConnection.callRestApi(ServerConnection.java:123)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreMetadata(JavaRunnerFactory.java:159)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreFromServer(JavaRunnerFactory.java:138)
at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.createRunner(JavaRunnerFactory.java:85)
at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:53)
at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:118)
at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:63)
2024-08-21T12:19:09.0033793Z 12:19:08.996 ERROR Error during SonarScanner CLI execution
2024-08-21T12:19:09.0034218Z java.lang.IllegalStateException: Error status returned by url [https://api.sonarcloud.io/analysis/jres?os=alpine&arch=x86_64]: 403
2024-08-21T12:19:09.0034557Z at org.sonarsource.scanner.lib.internal.http.ServerConnection.callUrl(ServerConnection.java:182)
2024-08-21T12:19:09.0034853Z at org.sonarsource.scanner.lib.internal.http.ServerConnection.callApi(ServerConnection.java:145)
2024-08-21T12:19:09.0035194Z at org.sonarsource.scanner.lib.internal.http.ServerConnection.callRestApi(ServerConnection.java:123)
2024-08-21T12:19:09.0035539Z at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreMetadata(JavaRunnerFactory.java:159)
2024-08-21T12:19:09.0035839Z at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreFromServer(JavaRunnerFactory.java:138)
2024-08-21T12:19:09.0036185Z at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.createRunner(JavaRunnerFactory.java:85)
2024-08-21T12:19:09.0036554Z at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:53)
2024-08-21T12:19:09.0036873Z at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:118)
2024-08-21T12:19:09.0037229Z at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
2024-08-21T12:19:09.0037496Z at org.sonarsource.scanner.cli.Main.main(Main.java:63)
2024-08-21T12:19:09.0882500Z ##[debug]Agent environment resources - Disk: / Available 150229.38 MB out of 451723.55 MB, Memory: Used 5696.00 MB out of 15997.00 MB, CPU: Usage 4.02%
2024-08-21T12:19:09.3222380Z ##[debug]Exit code 1 received from tool '/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner'
2024-08-21T12:19:09.3226293Z ##[debug]STDIO streams have closed for tool '/azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner'
2024-08-21T12:19:09.3232238Z ##[warning]Can't find loc string for key: LIB_ProcessExitCode
2024-08-21T12:19:09.3232961Z ##[debug]Processed: ##vso[task.issue type=warning;]Can't find loc string for key: LIB_ProcessExitCode
2024-08-21T12:19:09.3242682Z ##[warning]Error while executing SonarCloud:Analyze task: LIB_ProcessExitCode /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner 1
2024-08-21T12:19:09.3243723Z ##[debug]Processed: ##vso[task.issue type=warning;]Error while executing SonarCloud:Analyze task: LIB_ProcessExitCode /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner 1
2024-08-21T12:19:09.3244381Z ##[debug]task result: Failed
2024-08-21T12:19:09.3245184Z ##[error]LIB_ProcessExitCode /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner 1
2024-08-21T12:19:09.3245718Z ##[debug]Processed: ##vso[task.issue type=error;]LIB_ProcessExitCode /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner 1
2024-08-21T12:19:09.3255496Z ##[debug]Processed: ##vso[task.complete result=Failed;]LIB_ProcessExitCode /azp/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/2.3.2/sonar-scanner/bin/sonar-scanner 1
2024-08-21T12:19:09.3306044Z ##[section]Finishing: Sonar analyze
ALM used ( Azure DevOps) CI system used ( Azure DevOps) Scanner command used when applicable (private details masked) Languages of the repository React JS
Upvotes: 0
Views: 1434
Reputation: 13944
You can try to check with the following things:
On SonarCloud, open the project, and then navigate to "Administration" > "Analysis Method" > "Analyze a project with Azure DevOps Pipelines". Use the SonarCloud token displayed on step #2
(Add a new SonarCloud Service Endpoint
) to create a new SonarCloud service connection (or update the old service connection) in the project of Azure DevOps.
After creating/updating the new SonarCloud service connection, in the pipeline, configure the SonarCloud v2 tasks to use this new service connection.
Ensure the SonarCloud organization name, project key and name are consistent with that displayed on the step #3
(Configure Azure Pipeline
) on the "Administration" > "Analysis Method" > "Analyze a project with Azure DevOps Pipelines" page of SonarCloud.
EDIT:
Based on this case from Sonar Community, there is an known issue for Sonar Scanner CLI v6 that could cause 403 error.
From the logs you provided, we can see the version of Sonar Scanner CLI used by the task is 6.1.0.4477
.
On the SonarCloudPrepare@2
task, you can try to specify a different version using the input option "cliVersion
" (e.g., cliVersion: 5.0.1.3006
). Here is the released versions.
Upvotes: 1