在这里插入图片描述
这篇文章memo一下sonar-scanner和SonarQube版本不一致时导致的问题。

现象

使用sonar-scanner进行angular的typescript代码的质量扫描,执行时间非常之长,而且非常容易使得SonarQube服务挂掉。在等待的时间会提示如下的信息

...
WARN: [JOURNAL_FLUSHER] WARNING Journal flush operation took...
WARN: [JOURNAL_FLUSHER] WARNING Journal flush operation took...
...

再现环境

使用如下环境:

  • Sonar-Scanner: 4.2 (使用JDK 8,不实用sonar-scanner内嵌的JRE)
  • SonarQube: LTS 6.7.1

原因与对应方法

使用JDK 8 + Sonar-Scanner 3.2版本,连接SonarQube LTS 6.7.1多次试验,发现不会出现任何问题。基本上应该是版本兼容性问题。

注:此问题为并不是百分之百再现,另外,使用Sonar-Scanner 3.2 连接SonarQube LTS 6.7.1版本和SonarQube LTS 7.9.1版本并没有发现会使得SonarQube服务异常中断的问题。

sonar-scanner下载地址

下载地址:https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/

日志示例

/data/jenkins/workspace/angular-pipeline-job/demo # /usr/local/share/sonar/bin/s
onar-scanner \
>   -Dsonar.projectKey=demotest \
>   -Dsonar.sources=src \
>   -Dsonar.host.url=http://192.168.31.242:9000 \
>   -Dsonar.login=admin \
>   -Dsonar.password=admin
INFO: Scanner configuration file: /usr/local/share/sonar/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 1.8.0_212 IcedTea (64-bit)
INFO: Linux 4.9.87-linuxkit-aufs amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 6.7.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=179ms
INFO: Server id: AW37ZGoE3NR1qdRvdiBd
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=91ms
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=44ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=131ms
INFO: Load active rules
INFO: Load active rules (done) | time=1152ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=43ms
INFO: Project key: demotest
INFO: -------------  Scan demotest
INFO: Load server rules
INFO: Load server rules (done) | time=140ms
INFO: Base dir: /data/jenkins/workspace/angular-pipeline-job/demo
INFO: Working dir: /data/jenkins/workspace/angular-pipeline-job/demo/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 13 files indexed
INFO: Quality profile for ts: Sonar way
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=3ms
INFO: Sensor SonarTS [typescript]
INFO: Analyzing 8 typescript file(s) with the following configuration file /data/jenkins/workspace/angular-pipeline-job/demo/tsconfig.json
WARN: [JOURNAL_FLUSHER] WARNING Journal flush operation took 20,198ms last 8 cycles average is 2,524ms
...
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐