I’ve installed SonarQube on Kubernetes with a pipeline running on Gitlab.
I’ve committed 2 PHP files to a test repository and introduced some syntax errors to them.
Unfortunately, SonarQube dashboard does not show any errors, even though the pipeline is catching them.
The pipeline job is detecting these errors:
INFO: Starting PHP rules
INFO: 2 source files to be analyzed
ERROR: Unable to parse file [file:///builds/sonar-test/testcode/php/test.php] at line 4
ERROR: Parse error at line 4 column 1:
1: <?php
2:
3: phpinfo()
4:
^
ERROR: Unable to parse file [file:///builds/sonar-test/testcode/php/test-broken.php] at line 4
ERROR: Parse error at line 4 column 1:
1: <?php
2:
3: phpinfo()
4:
^
INFO: 2/2 source files have been analyzed
The pipeline job ends as successful:
INFO: QUALITY GATE STATUS: PASSED - View details on https://my-url/dashboard?id=test-project
INFO: Analysis total time: 29.535 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 33.209s
INFO: Final Memory: 17M/55M
INFO: ------------------------------------------------------------------------
Saving cache for successful job
00:01
Creating cache sonarqube-check-non_protected...
.sonar/cache: found 55 matching files and directories
Archive is up to date!
Created cache
Cleaning up project directory and file based variables
00:01
Job succeeded
However, when I go to SonarQube project / dashboard URL, it claims there are no errors.
Configuration:
$ cat .gitlab-ci.yml
sonarqube-check:
tags:
- test
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
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
script:
- sonar-scanner
allow_failure: true
only:
- sonarqube-test # or the name of your main branch
testjob:
tags:
- test
script:
- whoami
$ cat sonar-project.properties
sonar.projectKey=test-project
sonar.qualitygate.wait=true