Sonar拉取请求分析未显示任何度量或代码。

huangapple go评论50阅读模式
英文:

sonar pull request analysis is not showing any measures or code

问题

Hello, we have enterprise SQ setup on premis and it is setup to do pull request analyis with Sonar Gerrit plugin.

issues is that analysis shows no code or measures and just PASSED. is there a setting that am missing?

Sonar拉取请求分析未显示任何度量或代码。

sonar.host.url=http://sonar.team.com:9000

sonar.login=${env.SONAR_TOKEN}
sonar.projectKey=Services
sonar.sourceEncoding=UTF-8
sonar.scm.exclusions.disabled=true
sonar.test.inclusions=src/**/test/**/*
# Exclude test subdirectories from source scope
sonar.exclusions=src/**/test/*,src/**/test/**/*,src/**/**/*.tf
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

versions below

20:18:48.812 INFO: SonarScanner 4.7.0.2747
20:18:48.812 INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
20:18:48.812 INFO: Linux 5.4.0-65-generic amd64
20:18:48.941 DEBUG: keyStore is : 
20:18:48.941 DEBUG: keyStore type is : pkcs12
20:18:53.185 INFO: Analyzing on SonarQube server 9.2.4

we are forming the paths to source like below such that only changed files are scanned for. is this the right approach? if not how should we?

project_files=$(git diff @ @~1 --name-only | awk '{printf "%s,", $1}')
src_file_paths=$(echo ${project_files%,})
-Dsonar.sources=${src_file_paths}`

on sonarqube server gui we see under code tab No code files were found for analysis

logs

Issues to be commented: 0
Issues to be involved in score calculation: 0
Review has been sent

Jenkinsfile

                        withSonarQubeEnv('sonar.team.com') {
                            sh '''
                            src/jenkins/ci/pba.sh
                            '''.stripIndent()
                        }
                        sonarToGerrit(
                            inspectionConfig: [
                                    analysisStrategy: pullRequest()
                            ],


    sonar-scanner -X \
        -Dsonar.pullrequest.key="${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}" \
        -Dsonar.pullrequest.base="${GERRIT_BRANCH}" \
        -Dsonar.pullrequest.branch="${GERRIT_REFSPEC}" \
        -Dsonar.sources=${src_file_paths} \
        -Dsonar.exclusions=**/*.tf,src/**/test/*,src/**/test/**/*,src/**/**/*.tf
英文:

Helllo,
we have enterirpise SQ setup on premis and it is setup to do pull request analyis with Sonar Gerrit plugin.

issues is that analysis shows no code or measures and just PASSED. is there a setting that am missing?

Sonar拉取请求分析未显示任何度量或代码。

sonar.host.url=http://sonar.team.com:9000

sonar.login=${env.SONAR_TOKEN}
sonar.projectKey=Services
sonar.sourceEncoding=UTF-8
sonar.scm.exclusions.disabled=true
sonar.test.inclusions=src/**/test/**/*
# Exclude test subdirectories from source scope
sonar.exclusions=src/**/test/*,src/**/test/**/*,src/**/**/*.tf
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

versions below

20:18:48.812 INFO: SonarScanner 4.7.0.2747
20:18:48.812 INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
20:18:48.812 INFO: Linux 5.4.0-65-generic amd64
20:18:48.941 DEBUG: keyStore is : 
20:18:48.941 DEBUG: keyStore type is : pkcs12
20:18:53.185 INFO: Analyzing on SonarQube server 9.2.4

we are forming the paths to source like below such that only changed files are scanned for. is this the right approach? if not how should we?

project_files=$(git diff @ @~1 --name-only | awk '{printf "%s,", $1}')
src_file_paths=$(echo ${project_files%,})
-Dsonar.sources=${src_file_paths}`

on sonarqube server gui we see under code tab No code files were found for analysis

logs

Issues to be commented: 0
Issues to be involved in score calculation: 0
Review has been sent

Jenkinsfile

                        withSonarQubeEnv('sonar.team.com') {
                            sh '''
                            src/jenkins/ci/pba.sh
                            '''.stripIndent()
                        }
                        sonarToGerrit(
                            inspectionConfig: [
                                    analysisStrategy: pullRequest()
                            ],


    sonar-scanner -X \
        -Dsonar.pullrequest.key="${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}" \
        -Dsonar.pullrequest.base="${GERRIT_BRANCH}" \
        -Dsonar.pullrequest.branch="${GERRIT_REFSPEC}" \
        -Dsonar.sources=${src_file_paths} \
        -Dsonar.exclusions=**/*.tf,src/**/test/*,src/**/test/**/*,src/**/**/*.tf

答案1

得分: 1

   -Dsonar.inclusions=${scan_mr_files} \

其中 scan_mr_files 是提交或补丁集中发生更改的文件。

英文:

I had to specify inclusions and then code was populated on gui.

   -Dsonar.inclusions=${scan_mr_files} \

where scan_mr_files are the files that were changed in a commit or patchset.

huangapple
  • 本文由 发表于 2023年2月24日 05:46:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550651.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定