2017-04-03 51 views
1

我試圖在Travis上設置SonarQube.com對於Maven項目,但我看到以下異常的構建:未能執行目標org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:項目jraft上的sonar(default-cli):沒有治理許可

[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 

這裏是.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 

這裏是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 

爲什麼我看到這個錯誤No license for governance因爲我沒有使用任何商業聲納組件(只有sonar-java我想)?

這個問題似乎與其中一個插件需要商業密鑰有關,但我如何告訴Travis只安裝java插件?

+0

我無法重現你的問題的作品。不過,我在您的存儲庫(https://github.com/dzlab/jraft)上看到您未遵循「入門」指南中提供的基於Maven的項目(http://about.sonarqube.com/get -started /)。任何原因? –

+0

好的,我發現你的問題,看到我的答案在下面。 –

+0

@ Fabrice-SonarSourceTeam感謝您的反饋,但我沒有看到您回答! – bachr

回答

3

在你的資料庫以一看,你不應該忽略的是,特拉維斯附加被指定爲您的各種參數。

更具體地說,當你Maven的命令行上覆蓋SONAR_TOKEN(在line 12),其後果是,你已經加密,並且通過你的.travis.yml文件line 11令牌被徹底消滅了。正因爲如此,你的分析就像你是匿名一樣運行。

所以請遵循Get Started指導,只需運行以下命令的Maven:

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

謝謝刪除mvn調用中的所有附加參數構建工程! – bachr

+0

爲什麼在sonarqube源文件中他們正在給maven sonar插件設置附加參數https://github.com/SonarSource/sonarqube/blob/master/travis.sh#L147-L152 – bachr

+1

因爲他們沒有使用Travis附加組件 –

0

聲納治理插件是商業插件。 檢查here

..... 
[INFO] Download sonar-governance-plugin-2.0.0.1789.jar 
...... 
0

對我來說,下面從我的詹金斯管道

node{ 
    stage 'Code Quality' 
    sh "mvn sonar:sonar -Dsonar.host.url=http://<hostname>:9000" 
} 
相關問題