我试图在travis上为maven项目设置SonarQube.com,但我在构建时看到以下异常:
[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
,因为我没有使用任何商业声纳组件(我猜想只有声纳-java)?
问题似乎与其中一个插件需要商业密钥有关,但我怎么能告诉Travis只安装java插件?
答案 0 :(得分:3)
查看您的存储库,您不应该覆盖Travis Add-on为您指定的各种参数。
更具体地说,当您在Maven命令行(line 12)上覆盖SONAR_TOKEN
时,结果就是您在line 11加密并传递的令牌Get Started 1}}文件完全被删除。因此,您的分析就像是匿名一样运行。
因此,请按照{{3}}指南操作,然后运行以下Maven命令:
.travis.yml
答案 1 :(得分:0)
声纳治理插件是商业插件。 检查here
.....
[INFO] Download sonar-governance-plugin-2.0.0.1789.jar
......
答案 2 :(得分:0)
对我来说,下面的工作来自我的jenkins管道
node{
stage 'Code Quality'
sh "mvn sonar:sonar -Dsonar.host.url=http://<hostname>:9000"
}