- SonarQube v7.2.1 deployed from the Bitnami image (https://bitnami.com/stack/sonarqube) on a Google Cloud Debian instance.
- SonarQube Scanner v220.127.116.117
I’m trying to integrate SonarQube with Codeship but as per https://community.codeship.com/t/sonar-qube-integration/853/6 there’s no such integration.
Thus I opted for the manual route: I download and ‘install’ SonarQube Scanner directly into the Codeship box as such
# Download Sonar Scanner wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-18.104.22.1687-linux.zip # Unzip. unzip sonar-scanner-cli-22.214.171.1247-linux.zip # Add the Sonar Scanner `bin` directory to PATH. export PATH=./sonar-scanner-126.96.36.1997-linux/bin:$PATH
All configuration (including the host URL and auth information for the SonarQube server) exists within a
sonar-project.properties file committed in the project repo akin to this:
# Obfuscating the host for obvious reasons sonar.host.url=http://************* # This is an auth token sonar.login=*************************** sonar.projectKey=***** sonar.projectName=***** sonar.sources=./app sonar.sourceEncoding=UTF-8 # Set blob for the XUnit XML reports of the unit-testing. sonar.python.xunit.reportPath=xunit-reports/TEST-*.xml # Set blob for the Cobertura XML report of test-coverage. sonar.python.coverage.reportPath=coverage-reports/coverage.xml
And then I perform the scan with SonarQube Scanner from the project repo sending the results to the server as such:
# Delete xunit reports. if [ -d ./xunit-reports ]; then rm -rf xunit-reports/; fi # Delete coverage reports. if [ -d ./coverage-reports ]; then rm -rf coverage-reports/; fi # Run the unit-tests creating XUnit XML report files. coverage run --source app run_tests.py ~/google-cloud-sdk # Generate a Cobertura XML coverage report file. coverage xml -o coverage-reports/coverage.xml # Perform a Sonar scan of the code based on the config under `sonar-project.properties`. sonar-scanner
Now here’s the tricky part. Running
sonar-scanner -X on my local machine works just fine. All unit-test and coverage information is sent to the server in addition to the rest of the analysis data.
My issue is that the exact same config on Codeship fails to write coverage measures making coverage appear as 0% on the server when the project gets scanned on Codeship.
Running on local the scanner logs contain entries like this (obfuscated filenames):
15:46:48.841 INFO: Python test coverage 15:46:48.846 INFO: Parsing report '/*****/coverage-reports/coverage.xml' 15:46:48.942 DEBUG: Saving coverage measures for file '******' 15:46:48.947 DEBUG: Saving coverage measures for file '******'
Saving coverage measures entries however do not appear when running from Codeship. All I get is:
05:45:03.857 INFO: Python test coverage 05:45:03.861 INFO: Parsing report '/home/rof/clone/coverage-reports/coverage.xml'
The coverage files are identical on local and remote. Running
coverage report works and produces the same results on both environments.
Has anyone encountered issues like this before? Is there a way to debug this further and figure out what’s missing?