Type: New Feature
Affects Version/s: None
Fix Version/s: None
Component/s: Branch & PR
Production Notes:The change should be compatible with the Travis Addon. Once it has been deployed in production, the Travis Addon should be updated to remove all the part about branch/PR autodetection to only keep the scanner engine logic of this ticket.
Configuring analysis of branches and pull requests is not straightforward. Some parameters should be defined on the project itself, through the administration console, and some others through the scanner. The latter parameters are misleading and hard to tune on the heterogeneous CI environments.
Auto-configuration of scanner on the major CI services makes on-boarding easier. This approach has already been validated successfully for Bitbucket Pipelines and CirrusCI.
On TravisCI, the scanner properties should not be set by users. Values should be guessed by the scanner itself when it detects that runtime is TravisCI.
Runtime is considered as being TravisCI if the environment variable TRAVIS is true.
Analysis of pull request is configured if TRAVIS_PULL_REQUEST is not "false":
- sonar.pullrequest.provider is set to "github"
- sonar.pullrequest.key is provided by the env variable TRAVIS_PULL_REQUEST
- sonar.pullrequest.base is provided by the env variable TRAVIS_BRANCH
- sonar.pullrequest.branch is provided by the env variable TRAVIS_PULL_REQUEST_BRANCH
- sonar.pullrequest.github.repository is provided by the env variable TRAVIS_REPO_SLUG
- the Git revision used to feed Github Checks should be provided by the env variable TRAVIS_PULL_REQUEST_SHA, not by the SCM Git plugin.
Analysis of branch is configured if TRAVIS_PULL_REQUEST is "false" or empty:
- the Git revision used to feed Github Checks should be provided by the env variable TRAVIS_COMMIT, not by the SCM Git plugin.
- sonar.branch.name is provided by the env variable TRAVIS_BRANCH
- pull requests from forked repositories
- compatibility with Travis add-on
- documentation to be completed
- on-boarding tutorial