在 PR 上发布声纳报告时如何指定 github 凭据

how specify github credential when you plublish sonar-report on a PR

我使用此命令仅生成 PR 更新的代码的 sonnar 报告:

sh "mvn -Dsonar.host.url=http://sonarqube:9000\
                      -Dsonar.analysis.mode=preview\
                      -Dsonar.github.pullRequest=${env.BRANCH_NAME.substring(3)}\
                      -Dsonar.github.repository=***********\
                      -Dsonar.github.login=${env.GH_LOGIN} \
                      -Dsonar.github.password=${env.GH_PASSWORD} sonar:sonar \
                      -Dsonar.host.url=http://sonarqube:9000 \
                      -Dsonar.login=****** \
                      -Dsonar.password=*******    

问题是我有这个堆栈:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project jenkinscraft: Failed to execute project builder: 
org.sonar.plugins.github.PullRequestProjectBuilder: This operation requires a credential but none is given to the GitHub constructor

知道如何指定凭据吗?

您必须使用 sonar.github.oauth 属性 来指定 personal access token. This is documented in the GitHub plugin page