Sonar Cloud issue on Azure DevOps Pipelines Stage Failed

Hi Sonar Cloud community Team,

Quality gate passed in sonar cloud online portal but when passed in Azure Devops build pipelines they came as failed, there are multiple azure pipelines got failed due to this error

error details are below

##[error]ERROR: Error during SonarScanner execution ERROR: Error during SonarScanner execution
##[error]ERROR: Could not find a default branch for project with key ‘nps-service’. Make sure project exists. ERROR: Could not find a default branch for project with key ‘nps-service’. Make sure project exists.
##[error]ERROR: ERROR: ##[error]ERROR: Re-run SonarScanner using the -X switch to enable full debug logging. ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
##[error]The process ‘/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.45.0/sonar-scanner/bin/sonar-scanner’ failed with exit code 2

Hi,

Welcome to the community!

Could you

and post the log here, please?

 
Thx,
Ann

http://java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:181)%20##[error]at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)%20at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303)%20at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256)%20at%20java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:774)%20at%20java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:957)%20at%20java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:253)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:979)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:934)%20at%20java.base/java.util.ArrayList.forEach(ArrayList.java:1511)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:934)%20at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)%20at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303)%20at%20java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256)%20at%20java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:774)%20at%20java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:957)%20at%20java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:253)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:979)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:934)%20at%20java.base/java.util.ArrayList.forEach(ArrayList.java:1511)%20at%20java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:934)%20##[error]ERROR:%20ERROR:%20##[error]ERROR:%20Re-run%20SonarScanner%20using%20the%20-X%20switch%20to%20enable%20full%20debug%20logging.%20ERROR:%20Re-run%20SonarScanner%20using%20the%20-X%20switch%20to%20enable%20full%20debug%20logging.%20##[error]The%20process%20’/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.45.0/sonar-scanner/bin/sonar-scanner’%20failed%20with%20exit%20code%201%20Finishing:%20Run%20Code%20Analysis

Downloaded from central: https://repo.maven.apache.org/maven2/org/sonarsource/scanner/api/sonar-scanner-api/2.16.3.1081/sonar-scanner-api-2.16.3.1081.jar (625 kB at 10 MB/s) 
[WARNING] 05:55:19.342 Using RELEASE instead of an explicit plugin version may introduce breaking analysis changes at an unwanted time. It is highly recommended to use an explicit version, e.g. 'org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121'. 
[INFO] 05:55:19.366 Java 17.0.11 Eclipse Adoptium (64-bit) 
[INFO] 05:55:19.369 Linux 6.5.0-1021-azure (amd64) 
[INFO] 05:55:19.371 MAVEN_OPTS= -Xmx3072m 
[INFO] 05:55:19.400 User cache: /home/vsts/.sonar/cache 
[INFO] 05:55:20.106 Communicating with SonarCloud 
[INFO] 05:55:20.130 Default locale: "en", source code encoding: "UTF-8" 
[INFO] 05:55:20.847 Load global settings 
[INFO] 05:55:20.987 Load global settings (done) | time=142ms 
[INFO] 05:55:20.992 Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu 
[INFO] 05:55:21.157 Loading required plugins 
[INFO] 05:55:21.158 Load plugins index 
[INFO] 05:55:21.214 Load plugins index (done) | time=56ms 
[INFO] 05:55:21.214 Load/download plugins 
[INFO] 05:55:22.041 Load/download plugins (done) | time=827ms 
[INFO] 05:55:22.301 Found an active CI vendor: 'Azure DevOps' 
[INFO] 05:55:22.312 Load project settings for component key: 'com.mashreq.notification:e-notification-file-jobs' 
[INFO] Skipping e-notification-file-jobs 
[INFO] This project has been banned from the build due to previous failures. 
[INFO] ------------------------------------------------------------------------ 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 01:36 min 
[INFO] Finished at: 2024-06-03T05:55:49Z 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project e-notification-file-jobs: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator to check the permissions of the user the token belongs to -> [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] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException The process '/home/vsts/work/1/s/maven/apache-maven-3.6.3/bin/mvn' failed with exit code 1 Could not retrieve code analysis results - Maven run failed. Result Attachments will be stored in LogStore Run Attachments will be stored in LogStore ##
[error]Build failed. Async Command Start: Publish test results Publishing test results to test run '162'. TestResults To Publish 55, Test run id:162 Test results publishing 55, remaining: 0. Test run id: 162 Published Test Run : https://dev.azure.com/MashreqRetail/CI-CD/_TestManagement/Runs?runId=162&_a=runCharts Async Command End: Publish test results

Hi Team, We are facing Sonar Cloud issue with multiple Azure Pipelines, can you please help here, error code shared below

#[error]at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230) at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303) at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256) at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:774) at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:957) at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:253) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:979) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:934) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:934) at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230) at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303) at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256) at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:774) at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:957) at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:253) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:979) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:934) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:934) ##[error]ERROR: ERROR: ##[error]ERROR: Re-run SonarScanner using the -X switch to enable full debug logging. ERROR: Re-run SonarScanner using the -X switch to enable full debug logging. ##[error]The process ‘/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.45.0/sonar-scanner/bin/sonar-scanner’ failed with exit code 1 Finishing: Run Code Analysis

Hi,

Once I formatted your logs, it was much easier to see this:

Specifically:

Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable,

Can you double-check these things and make sure they’re specified properly?

 
Thx,
Ann

New SONAR_TOKEN has been created and configured azure pipelines, still we are facing same issue, requesting you support

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project rcms-eg-ccpl-jobs: Could not find a default branch for project with key ‘com.mashreq.rcms:rcms-eg-ccpl-jobs’. Make sure project exists. → [Help 1]

Hi,

There are three items in that error message:

  • SONAR_TOKEN
  • sonar.projectKey
  • sonar.organization

To be getting this message, one or more of them is missing or incorrect.

Does the user your token came from have analyze permissions on the project in question?

 
Ann

we created SONAR_TOKEN with administrator privilege still getting same error

Hi,

I don’t know what to tell you. I don’t think I’ve ever seen a case of this error, where the problem wasn’t with one of these three:

 
Ann

Hi again,

Is it possible your Azure PAT has expired?

 
Ann

Hi Ann Campbell,
New PAT was created and working normal, post update PAT, I am creating new Build pipelines again getting same error
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project rcms-eg-ccpl-jobs: Could not find a default branch for project with key ‘com.mashreq.rcms:rcms-eg-ccpl-jobs’. Make sure project exists. → [Help 1]

please advice

Hi,

Then we’re back to this:

 
Ann

INFO] Skipping kore-service 
[INFO] This project has been banned from the build due to previous failures. 
[INFO] ------------------------------------------------------------------------ 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time:  01:40 min 
[INFO] Finished at: 2024-07-03T08:57:57Z 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project kore-service: Could not find a default branch for project with key 'com.mashreq:kore-service'. Make sure project exists. -> 
[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] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException The process '/home/vsts/work/1/s/maven/apache-maven-3.6.3/bin/mvn' failed with exit code 1 Could not retrieve code analysis results - Maven run failed. No test result files matching /home/vsts/work/1/s/**/TEST-*.xml were found, so publishing JUnit test results is being skipped. ##
[error]Build failed. Finishing: Package

Hi Team,
we are getting above mentioned error, requesting your help to resolve the issue.

Thanks

Hi,

This is a new question. It deserves a new thread. With all the details, please.

 
Thx,
Ann