Can sonarqube gitlab plugin only scan changed files

落花浮王杯 提交于 2019-12-13 03:48:00

问题


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

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

Is there anything wrong with my configurations?


回答1:


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.

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, ...).

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.



来源:https://stackoverflow.com/questions/52360922/can-sonarqube-gitlab-plugin-only-scan-changed-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!