Must-share information (formatted with Markdown):
-
which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
- SonarQube CE 10.4.1
- Jenkins 2.454
- SonarQube Scanner for Jenkins 2.17.2
-
how is SonarQube deployed: zip, Docker, Helm
- Docker
-
what are you trying to achieve
- Scan the code in a pull-request using SonarQube
-
what have you tried so far to achieve this
- not relevant
Description of the issue:
- We have a repo with a base-branch of “main”
- We use the above setup with Jenkins shared libraries to trigger a SonarQube scan on branch pull and pull request instantiation
- With each pull request, we feed SonarQube (through the scanner plugin) with the base-branch through the sonar.pullrequest.base param
- When we configure the base-branch to “master” while the base-branch should be main, SonarQube cannot perform a compare and list the new code smells
- SonarQube Scanner correctly logs an error in the output, as seen below
- However, SonarQube Scanner still exits with exit-code 0 (everything’s fine) and the Jenkins pipeline continues as normal
ERROR Error during SonarScanner CLI execution
ERROR No branch exists in Sonarqube with the name master
ERROR
ERROR Re-run SonarScanner CLI using the -X switch to enable full debug logging
Expected behavior:
- We expect the scanner to exit with a non-0 exit code, so Jenkins will consider the scan to have failed with a error.
Workaround:
We could capture and scan the output for these specific errors, but this seems like a ducktape patch instead of a more consistent behaviour of exiting with a non-0 exit code. For example, see OWASP Dependency Check’s error code:
0: No vulnerabilities were found.
1: An error occurred while running the check (e.g., a file couldn't be read, or the configuration is incorrect).
11: Analysis exception occurred (likely due to a setup or execution problem).
12: Dependencies were identified with vulnerabilities (no threshold exceeded).
13: Unable to continue due to fatal initialization error.
14: One or more invalid configuration files encountered.
15: Dependencies were identified with vulnerabilities that exceed the specified vulnerability threshold (your case).
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!