Need some help understand how this occurs. We moved to sonarcloud and every repository that uses this shared jenkins pipeline has been scanning successfully for a month or so, but recently we have had a few repositories that have started to fail due to this error. These repos were working fine before. We did have a new repository that failed on its initial scan.
We don’t import them into sonarcloud. We use the sonar-scanner cli to initiate the scan.
I found another community message along these lines, but I’m still struggling to understand why this happens for previously working and new repos. Any help would be appreciated.
- ALM used - Github
- CI system used - Jenkins running sonar-scanner container image which uses the Docker plugin with shared volume so it has access to the source files and test outputs
- Scanner command used
docker run -t -d -u 1000:1000 -v /workspace:/usr/src -e "SONAR_SCANNER_OPTS=-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=****** -Dsonar.organization=my_org -Dsonar.projectName=project-ts -Dsonar.projectVersion=2.106.0 -Dsonar.branch.name=develop -Dsonar.projectKey=project-ts"
- Languages of the repository
typescript - Error observed
13:28:53 + sonar-scanner
13:28:53 INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
13:28:53 INFO: Project root configuration file: /tmp/****-e9f83b7e/workspace/Fleet Management/hpnotiq-ts/sonar-project.properties
13:28:53 INFO: SonarScanner 4.8.0.2856
13:28:53 INFO: Java 11.0.18 Alpine (64-bit)
13:28:53 INFO: Linux 4.19.0-16-cloud-amd64 amd64
13:28:53 INFO: SONAR_SCANNER_OPTS=-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=****** -Dsonar.organization=my_org -Dsonar.projectName=project-ts -Dsonar.projectVersion=2.106.0 -Dsonar.branch.name=develop -Dsonar.projectKey=project-ts
13:28:52 $ docker top c57a3e51593f78fbc057d5fd6a7dce81146cb85929b9162e38b293aeccaa52a9 -eo pid,comm
13:28:54 INFO: User cache: /opt/sonar-scanner/.sonar/cache
13:28:59 INFO: Analyzing on SonarCloud
13:28:59 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
13:28:59 INFO: Load global settings
13:29:00 INFO: Load global settings (done) | time=563ms
13:29:00 INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
13:29:00 INFO: User cache: /opt/sonar-scanner/.sonar/cache
13:29:00 INFO: Load/download plugins
13:29:00 INFO: Load plugins index
13:29:01 INFO: Load plugins index (done) | time=505ms
13:29:33 INFO: Load/download plugins (done) | time=28025ms
13:29:33 INFO: Loaded core extensions: developer-scanner
13:29:33 INFO: Found an active CI vendor: 'Jenkins'
13:29:33 INFO: Load project settings for component key: 'project-ts'
13:29:33 INFO: Process project properties
13:29:33 INFO: Execute project builders
13:29:33 INFO: Execute project builders (done) | time=1ms
13:29:33 INFO: Project key: project-ts
13:29:33 INFO: Base dir: /tmp/****-e9f83b7e/workspace/Project/project-ts
13:29:33 INFO: Working dir: /tmp/****-e9f83b7e/workspace/Project/project-ts/.scannerwork
13:29:33 INFO: Load project branches
13:29:33 INFO: Load project branches (done) | time=472ms
13:29:33 INFO: Check ALM binding of project 'project-ts'
13:29:33 INFO: Detected project binding: NONEXISTENT
13:29:33 INFO: Check ALM binding of project 'project-ts' (done) | time=474ms
13:29:33 INFO: Load project pull requests
13:29:33 INFO: Load project pull requests (done) | time=485ms
13:29:33 INFO: Load branch configuration
13:29:33 INFO: ------------------------------------------------------------------------
13:29:33 INFO: EXECUTION FAILURE
13:29:33 INFO: ------------------------------------------------------------------------
13:29:33 INFO: Total time: 38.594s
13:29:33 INFO: Final Memory: 20M/88M
13:29:33 INFO: ------------------------------------------------------------------------
13:29:33 ERROR: Error during SonarScanner execution
13:29:33 ERROR: Could not find a default branch to fall back on.
13:29:33 ERROR:
13:29:33 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
- Steps to reproduce
Unbound repository
All default settings and no analysis configuration setup
Executing this command in the job or even run locally produces the same result - Potential workaround
Running sonar-scanner with the same command but leaving the -Dsonar.branch.name= empty.