7

Does anyone knows for which reasons a SonarQube Scanner analysis could be skipped ?

$ sonar-scanner -X -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
08:59:10.162 INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties
08:59:10.166 INFO: Project root configuration file: /home/travis/build/armadito/glpi/plugins/armadito/sonar-project.properties
08:59:10.182 INFO: SonarQube Scanner analysis skipped
The command "sonar-scanner -e -X -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN" exited with 0.
vhamon
  • 637
  • 4
  • 12

2 Answers2

7

Finally, I found out that travis-ci's sonarqube addon set by itself the following environnment variable :

export SONARQUBE_SKIPPED=true

With the following message :

Skipping SonarQube Scan because this branch is not master or it does not match declared branches

Indeed, I was working on a different branch: DEV.

Thus, the solution is the following, in .travis.yml :

sonarqube:
    branches :
    - DEV

And in sonar-project.properties :

sonar.branch=DEV
vhamon
  • 637
  • 4
  • 12
  • I've added this to my yml file but it changed nothing. Do you have a suggestion on how to debug it? – CaptainNemo Dec 18 '16 at 05:44
  • 1
    There is actually a recent issue on github : https://github.com/travis-ci/travis-ci/issues/6977 – vhamon Dec 19 '16 at 10:47
  • Try add sonar.branch=Your_branch in your sonarproject.properties. – vhamon Dec 19 '16 at 10:54
  • the issue you posted offered the perfect solution – CaptainNemo Dec 19 '16 at 18:00
  • I'm not sure how the various config files hang together (and haven't read the docs, because I'm a bad person), but I don't have a sonar-project.properties file, and don't seem to need it; for me just adding my branch name to the .travis.yml was enough. – DaveyDaveDave Apr 13 '17 at 10:53
0

I have added branch under addons in travis.yml and also sonar branch in sonar properties file, but still SonarQube analysis gets skipped. how to fix this?

addons: sonarqube: token: secure: "XXXXXXXXXXXXXXXXXXXXXXXXXX" branches :

develop added in travis.yml

and in sonar-project.properties, I have added this key as well sonar.branch=develop

but travis has always this $ export SONARQUBE_SKIPPED=true

0.41s$ sonar-scanner

INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties

INFO: Project root configuration file: /home/........../sonar-project.properties

INFO: SonarQube Scanner analysis skipped

Papitha
  • 1
  • 1