上下文: 现在我有一个由一些Gerrit事件触发的Jenkins自由式作业。当它被触发时,它会下载更改并对它们运行Sonarqube分析。分析完成后,应该发布关于Gerrit详细说明结果的评论。
不幸的是,无论Sonarqube分析的结果是什么,评论总是说"没有找到sonarqube违规行为。"
版本:
Jenkins v2.46.2
Gerrit Trigger Plugin v.2.24.0
Sonar Gerrit Plugin v2.0
Jenkins插件的Sonarqube扫描仪v2.6.1
Sonarqube v6.3.1
Gerrit v2.13.5
Jenkins控制台的输出:
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/3.0.3.778/sonar-scanner-cli-3.0.3.778.zip to /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar on ubuntu-graphical
[osstp-ci] $ /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/bin/sonar-scanner -e -Dsonar.host.url=<ip_address>:9000 -Dsonar.projectName=osstp-work -Dsonar.issuesReport.json.enable=true -Dsonar.report.export.path=sonar-report.json -Dsonar.analysis.mode=preview -Dsonar.projectKey=org.vmware:osstpmgt -Dsonar.inclusions=**/*.py -Dsonar.host.url=http://10.20.96.87:9000 -Dsonar.sources=. -Dsonar.projectBaseDir=/var/jenkins/workspace/osstp-ci
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_131 Oracle Corporation (64-bit)
INFO: Linux 4.8.0-36-generic amd64
INFO: User cache: /home/tgong/.sonar/cache
INFO: Load global settings
INFO: Load global settings (done) | time=160ms
INFO: User cache: /home/tgong/.sonar/cache
INFO: Exclude plugins: devcockpit, ldap, authgithub, authbitbucket, pdfreport, authaad, googleanalytics, governance
INFO: Load plugins index
INFO: Load plugins index (done) | time=10ms
INFO: Download sonar-csharp-plugin-5.7.0.612.jar
INFO: Download sonar-python-plugin-1.7.0.1195.jar
INFO: Download sonar-java-plugin-4.5.0.8398.jar
INFO: Download sonar-flex-plugin-2.3.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-php-plugin-2.9.2.1744.jar
INFO: Download sonar-scm-svn-plugin-1.4.0.522.jar
INFO: Download sonar-javascript-plugin-2.20.0.4207.jar
INFO: SonarQube server 6.3.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=217ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=66ms
INFO: Load active rules
INFO: Load active rules (done) | time=1693ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=141ms
INFO: Issues mode
INFO: Scanning only changed files
INFO: Project key: org.vmware:osstpmgt
INFO: ------------- Scan osstp-work
INFO: Load server rules
INFO: Load server rules (done) | time=68ms
INFO: Base dir: /var/jenkins/workspace/osstp-ci
INFO: Working dir: /var/jenkins/workspace/osstp-ci/.scannerwork
INFO: Source paths: .
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Included sources:
INFO: **/*.py
WARN: Not indexing due to symlink loop: /var/jenkins/workspace/osstp-ci/www/scotzilla
INFO: 717 files indexed
INFO: 2093 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for py: Sonar way
INFO: Sensor NoSonar Sensor [php]
INFO: Sensor NoSonar Sensor [php] (done) | time=1ms
INFO: Sensor Coverage Report Import [csharp]
INFO: Sensor Coverage Report Import [csharp] (done) | time=1ms
INFO: Sensor Coverage Report Import [csharp]
INFO: Sensor Coverage Report Import [csharp] (done) | time=0ms
INFO: Sensor Unit Test Results Import [csharp]
INFO: Sensor Unit Test Results Import [csharp] (done) | time=1ms
INFO: Sensor XmlFileSensor [java]
INFO: Sensor XmlFileSensor [java] (done) | time=7ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=8ms
INFO: Load server issues
INFO: Load server issues (done) | time=1053ms
INFO: Performing issue tracking
INFO: 813/813 components tracked
INFO: Export issues to /var/jenkins/workspace/osstp-ci/.scannerwork/sonar-report.json
INFO: ANALYSIS SUCCESSFUL
INFO: Task total time: 11.610 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 17.577s
INFO: Final Memory: 46M/114M
INFO: ------------------------------------------------------------------------
Getting Sonar Report from: /var/jenkins/workspace/osstp-ci/.scannerwork/sonar-report.json
Report has loaded and contains 1492 issues
Connected to Gerrit: server name: Gerrit. Change Number: 32, PatchSetNumber: 1
Review has been sent
Finished: SUCCESS
答案 0 :(得分:2)
不确定您是否已经解决了这个问题,但是您的&#34;项目设置&#34;条目是空的,最近的修复(2018年1月 - JENKINS-43730)解决了可能导致您的问题:https://wiki.jenkins.io/display/JENKINS/Sonar+Gerrit#SonarGerrit-Version2.1(6Jan2018)
答案 1 :(得分:1)
尝试设置以下内容:
1)构建&gt;执行SonarQube扫描仪&gt;分析属性
sonar.report.export.path=sonar-report.json
2)构建后的操作&gt;发布SonarQube问题作为Gerrit评论&gt;项目设置
SonarQube report path = .sonar/sonar-report.json
答案 2 :(得分:0)
似乎未设置user.dir
属性。将它设置为git下载代码的位置(最有可能在$WORKSPACE
)
所以,请将此user.dir=$WORKSPACE
包含在其他分析参数中。