Sonarqube Gitlab插件只能扫描更改的文件吗 [英] Can sonarqube gitlab plugin only scan changed files

查看:463
本文介绍了Sonarqube Gitlab插件只能扫描更改的文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gitlab-ci管道,它将使用以下命令运行一个新的docker容器:

I'm using gitlab-ci pipeline, it will run a new docker container with following commands:

mvn --batch-mode verify sonar:sonar 
-Dsonar.analysis.mode=preview 
-Dsonar.gitlab.project_id=$CI_PROJECT_ID 
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA 
-Dsonar.gitlab.only_issue_from_commit_file=true 
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME 
-Dsonar.host.url=xxx 
-Dsonar.test.inclusions="/src/test/java/**/*.java" 
-Dsonar.login=xxx

对于我的项目而言,它变得相当慢,几乎要运行20分钟. 我发现它将扫描所有文件,而不是仅扫描已提交的文件.

It becomes quite slow for my project, almost run for 20mins. I found it will scan all files instead of only the commited files.

我的配置有问题吗?

推荐答案

在某些过去的SonarQube版本中,我们将预览模式更改为仅扫描更改的文件.但这有一些缺点,例如无法正确检测跨文件问题.

In some past SonarQube versions we changed the preview mode to only scan changed files. But it has some drawback, like not being able to properly detect cross file issues.

在SonarQube的最新版本中,不赞成使用预览模式,而希望进行拉取请求分析.但是,即使是这种PR分析功能,出于相同的原因(跨文件问题,覆盖率措施,重复检测等),也正在扫描所有文件.

In recent SonarQube versions, the preview mode is deprecated in favor of pull request analysis. But even this PR analysis feature is scanning all files, for the same reasons (cross file issues, coverage measures, duplication detections, ...).

我们不再尝试进行部分分析,而是尝试优化整个分析时间.您的项目有多大?与常规构建(编译+测试)相比,SonarQube分析时间长吗?如果是,那么我建议您在 SonarSource社区论坛中报告您的情况.

We stopped trying to do partial analysis, and are instead trying to optimize full analysis duration. How big is your project? Is SonarQube analysis time long compared to your regular build (compile + tests)? If yes, then I suggest you report you case on the SonarSource community forum.

这篇关于Sonarqube Gitlab插件只能扫描更改的文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆