Adding Pull Request Analysis (in GitHub Pull Request decoration for sample), configuring parameters could be a little tricky.
You have parameters:
- On build:
sonar.pullrequest.key
/ sonar.pullrequest.branch
/ sonar.pullrequest.base
; to set on build - On project config:
sonar.pullrequest.provider
/ sonar.pullrequest.github.repository
; to configure in UI
All these parameters could be retrieved from TeamCity build parameters (at least for GitHub). If it can be provisionned by a TeamCity Build Feature, it would be great !!
This feature request is like the Using SonarCloud with Travis CI, which is very usefull.
Technically, it seems to work with the SONARQUBE_SCANNER_PARAMS system environment variable ; available since SonarQube Scanner API v2.7 (SCANNERAPI-159) & SonarQube Scanner for Maven v3.1 (MSONAR-147).
Content of this sysenv depending the build (Here GitHub+Travis classic & PR builds):
# Classic Build
SONARQUBE_SCANNER_PARAMS = { "sonar.organization" : "axel3rd-github", "sonar.host.url" : "https://sonarcloud.io" }
# PullRequest build
SONARQUBE_SCANNER_PARAMS = { "sonar.pullrequest.key" : "1", "sonar.pullrequest.branch" : "branch", "sonar.pullrequest.base" : "master", "sonar.pullrequest.provider" : "GitHub", "sonar.pullrequest.github.repository" : "axel3rd/sysenv-travis-watcher", "sonar.organization" : "axel3rd-github", "sonar.host.url" : "https://sonarcloud.io" }
And you are right, if these data (PR feature) can be used, the mapping can be done more easiest than some build parameters.
Currently I can see for GitHub PR (EDITED 24/10: Update with last TW-61490 remark ; Pull Requests TeamCity plugin version 66559 at min).
SonarQube parameter | TeamCity parameter | Remark |
---|
sonar.pullrequest.key | teamcity.pullRequest.number | -- |
sonar.pullrequest.branch | teamcity.pullRequest.title | Used in SonarQube UI only |
sonar.pullrequest.base | teamcity.pullRequest.target.branch |
|
sonar.pullrequest.provider | To extract from vcsroot.url | In discussion in TW-61490 |
sonar.pullrequest.github.repository | vcsroot.url | With an extract from complete SCM URL (before last \ , or .*github.*/(.*)/(.*) --> \1/\2 ) |
sonar.organization | -- | Seems not used into SonarQube |
sonar.host.url | Defined in plugin configuration, or require #70 |
|