Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project jraft: No license for governance

bachr picture bachr · Apr 3, 2017 · Viewed 8.3k times · Source

I'm trying to setup SonarQube.com on travis for a maven project, but I see the following exception on build:

[INFO] User cache: /home/travis/.sonar/cache
[INFO] Load global settings
[INFO] Load global settings (done) | time=456ms
[INFO] User cache: /home/travis/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=16ms
[INFO] Download sonar-scm-cvs-plugin-1.0.jar
[INFO] Download sonar-scm-svn-plugin-1.3.jar
[INFO] Download sonar-plsql-plugin-2.9.0.901.jar
[INFO] Download sonar-csharp-plugin-5.8.0.660.jar
[INFO] Download sonar-java-plugin-4.7.1.9272.jar
[INFO] Download sonar-web-plugin-2.5.0.476.jar
[INFO] Download sonar-flex-plugin-2.3.jar
[INFO] Download sonar-xml-plugin-1.4.2.885.jar
[INFO] Download sonar-vbnet-plugin-3.0.3.346.jar
[INFO] Download sonar-swift-plugin-2.0.0.1127.jar
[INFO] Download sonar-python-plugin-1.7.0.1195.jar
[INFO] Download sonar-github-plugin-1.4.0.699.jar
[INFO] Download sonar-cfamily-plugin-4.6.0.7071.jar
[INFO] Download sonar-auth-github-plugin-1.3.jar
[INFO] Download sonar-rpg-plugin-2.1.0.736.jar
[INFO] Download sonar-scm-mercurial-plugin-1.1.1.jar
[INFO] Download sonar-googleanalytics-plugin-1.1.jar
[INFO] Download sonar-widget-lab-plugin-1.8.1.jar
[INFO] Download sonar-pli-plugin-1.5.0.702.jar
[INFO] Download sonar-javascript-plugin-2.21.0.4409.jar
[INFO] Download sonar-groovy-plugin-1.4.jar
[INFO] Download sonar-cobol-plugin-3.3.1.1636.jar
[INFO] Download sonar-scm-git-plugin-1.2.jar
[INFO] Download sonar-php-plugin-2.10.0.2087.jar
[INFO] Download sonar-abap-plugin-3.3.jar
[INFO] Download sonar-governance-plugin-2.0.0.1789.jar
[INFO] Download qualinsight-sonarqube-badges-3.0.1.jar
[INFO] SonarQube version: 6.3.0
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:42 min
[INFO] Finished at: 2017-04-03T09:47:20+00:00
[INFO] Final Memory: 70M/468M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project jraft: No license for governance -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Here is the .travis.yml:

language: java
jdk:
  - oraclejdk8

addons:
  sonarqube:
    organization: ${SONAR_ORGANIZATION}
    token:
      secure: ${SONAR_TOKEN}

script:
  - ./travis.sh

cache:
  directories:
    - $HOME/.m2/repository
    - $HOME/.sonar
    - $HOME/jvm
    - $HOME/maven

Here is the travis.sh:

#!/bin/bash

set -e

INITIAL_VERSION=1.0-SNAPSHOT

export MAVEN_OPTS="-Xmx1G -Xms128m"

mvn package sonar:sonar \
  $MAVEN_ARGS \
  -Dsonar.host.url=$SONAR_HOST_URL \
  -Dsonar.login=$SONAR_TOKEN \
  -Dsonar.projectVersion=$INITIAL_VERSION

Why I am seeing this error No license for governance as I am not using any commercial sonar component (only sonar-java I suppose)?

The problem seems to be related to the fact that one of the plugins needs a commercial key, but How I can tell Travis to only install the java plugin?

Answer

Taking a look at your repository, you should not override the various parameters that the Travis Add-on is specifying for you.

More specifically, when you override SONAR_TOKEN on the Maven command line (at line 12), the consequence is that the token that you have encrypted and passed at line 11 of your .travis.yml file is completely wiped out. Because of this, your analysis is run like if you were anonymous.

So please follow the Get Started guide and simply run the following Maven command:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar