Reputation: 2086
I'm trying to run Sonar scans at Github's Pull Requests from Drone.io.
This is the sequence:
This is the command used in Drone's build:
gradle/wrapper all sonarqube \
-Dsonar.analysis.mode=preview \
-Dsonar.github.pullRequest=$DRONE_BUILD_NUMBER \
-Dsonar.github.oauth=<github_token>
I cannot find the PR ID in the Drone environment. Do you know if there is an alternative?
Upvotes: 1
Views: 874
Reputation: 2563
The pull request number is available in the DRONE_PULL_REQUEST
environment variable [1]
You can see a list of all environment variables by dumping them to your build logs. This can be done by adding the env
command to your yaml:
pipeline:
build:
image: golang
commands:
- env # dump environment variables
You will see something like this in your build logs:
...
DRONE_PULL_REQUEST=42
DRONE_BUILD_EVENT=pull_request
...
Note that the pull request is only set when Drone is building a pull request hook. You can confirm this by looking at the build event environment variable (above)
[1] http://readme.drone.io/usage/environment-reference/
Upvotes: 1