我能够从与Jenkins集成的Sonarqube中获得正常的静态分析,但是当我尝试在Git中进行PR分析时,我无法获得它。
必须共享的信息(使用Markdown格式化):
我正在使用哪个版本(SonarQube,扫描仪,插件)
7.6版SonarQube,适用于Jenkins的SonarQube扫描仪(2.8.1版插件)
我要实现的目标:
我正在尝试实现将PR分析显示在Git中以显示每个PR。
到目前为止我为实现这一目标所做的尝试:
我已经安装了Sonarqube相关的插件和GIT Pull Request Builder PLugin,并且在配置它的方式上,在Git端添加了一个webhook,以便为每个PR触发该钩子。在Jenkins端,我在Jenkins> Configuration中设置了SonarQube服务器的值。我已经提到了Name,Server URL和Server身份验证令牌。
在工作本身中,我指定了以下内容
GitHub项目
IN源代码管理:
我已将Refspec用于+refs/pull/:refs/remotes/origin/pr/
和分支指定者${sha1}
IN构建触发器:
我已经使用我使用凭据生成的GitHub API凭据检查了GitHub Pull Request Builder。
并选中了“使用github挂钩进行构建触发”
在内部版本中: 我选择了Execute SonarQube Scanner和
sonar.projectKey=name
sonar.projectName=name
sonar.version=“1.0”
sonar.sources=.
sonar.inclusions=src/flask/,src/framework/backend/
sonar.projectVersion=1.0
sonar.scm.provider=git
sonar.pullrequest.provider=github
sonar.pullrequest.github.endpoint=https://github.company.com/api/v3/
sonar.verbose=true
-Dsonar.sourceEncoding=UTF-8
-Dsonar.analysis.mode=preview
-Dsonar.github.repository=org/repo
-Dsonar.verbose=true
-Dsonar.github.pullRequest=${ghprbPullId}
-Dsonar.host.url=my sonarqube url
-Dsonar.github.login=jenkins
-Dsonar.github.oauth=my github oauth
-Dsonar.login=my token for sonar login
在创建PR结束所有这些之后,我看到作业正在按预期触发,输出显示如下:
13:22:35.366 INFO: ------------- Run sensors on project
13:22:35.371 DEBUG: Sensors :
13:22:35.373 INFO: No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.
13:22:35.379 INFO: Load server issues
13:22:35.399 DEBUG: GET 200 http://sonarqube.slc.efscloud.net/batch/issues.protobuf?key=PRAnalysisforReplibit | time=19ms
13:22:35.402 INFO: Load server issues (done) | time=23ms
13:22:35.403 INFO: Performing issue tracking
13:22:35.535 DEBUG: ‘src/flask/core/alerts/alerts-cli’ generated metadata with charset ‘UTF-8’
13:22:35.546 DEBUG: ‘src/flask/cert.pem’ generated metadata with charset ‘UTF-8’
13:22:35.582 DEBUG: ‘src/flask/core/connect_wise/README.md’ generated metadata with charset ‘UTF-8’
13:22:35.600 DEBUG: Failed to detect a valid charset for file ‘src/flask/vaulttransferclient’. Using default charset.
13:22:35.602 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vaulttransferclient at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:36.012 DEBUG: ‘src/flask/vaulttransferclient’ generated metadata with charset ‘UTF-8’
13:22:36.204 DEBUG: Failed to detect a valid charset for file ‘src/flask/cloudserver’. Using default charset.
13:22:36.204 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/cloudserver at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:37.128 DEBUG: ‘src/flask/cloudserver’ generated metadata with charset ‘UTF-8’
13:22:37.946 DEBUG: Failed to detect a valid charset for file ‘src/flask/vaulttransferserver’. Using default charset.
13:22:37.946 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vaulttransferserver at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.118 DEBUG: ‘src/flask/vaulttransferserver’ generated metadata with charset ‘UTF-8’
13:22:38.290 DEBUG: ‘src/framework/backend/Readme’ generated metadata with charset ‘UTF-8’
13:22:38.298 DEBUG: ‘src/flask/gen-py/cloudAgent/BackupAgent-remote’ generated metadata with charset ‘UTF-8’
13:22:38.309 DEBUG: ‘src/flask/gen-py/cloudAgent/BackupManager-remote’ generated metadata with charset ‘UTF-8’
13:22:38.362 DEBUG: ‘src/flask/unittest.cfg’ generated metadata with charset ‘UTF-8’
13:22:38.364 DEBUG: ‘src/flask/gen-py/cloudAgent/EndpointManager-remote’ generated metadata with charset ‘UTF-8’
13:22:38.403 DEBUG: Failed to detect a valid charset for file ‘src/flask/vhdtool’. Using default charset.
13:22:38.403 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vhdtool at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.404 DEBUG: ‘src/flask/vhdtool’ generated metadata with charset ‘UTF-8’
13:22:38.409 DEBUG: Failed to detect a valid charset for file ‘src/flask/add_mbr’. Using default charset.
13:22:38.409 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/add_mbr at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.413 DEBUG: ‘src/flask/add_mbr’ generated metadata with charset ‘UTF-8’
13:22:38.447 INFO: 331/331 components tracked
13:22:38.448 INFO: Load server rules
13:22:38.691 DEBUG: GET 200 http://sonarqube.slc.efscloud.net/api/rules/list.protobuf | time=243ms
13:22:38.711 INFO: Load server rules (done) | time=263ms
13:22:38.746 INFO: ANALYSIS SUCCESSFUL
13:22:38.748 DEBUG: Post-jobs :
13:22:38.751 INFO: Analysis total time: 16.346 s
13:22:38.806 INFO: ------------------------------------------------------------------------
13:22:38.806 INFO: EXECUTION SUCCESS
13:22:38.807 INFO: ------------------------------------------------------------------------
13:22:38.807 INFO: Total time: 17.787s
13:22:38.963 INFO: Final Memory: 32M/412M
13:22:38.963 INFO: ------------------------------------------------------------------------
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
Setting status of 77ef22e038167d7159276c4b24ea10b5a14d732a to SUCCESS with url and message: 'Build finished. ’
Finished: SUCCESS
最后,我在评论中没有得到分析。我在哪里做错了。请帮助大家。我是SonarQube的新手,这是我要与我们的Jenkins实例集成的开发人员版本。
预期结果是GIT中每个PR的代码分析。