I having issues with Drone + Sonar + Github when the pull requests is opened, my PR don’t get the sonar analysis when the drone clone is enabled.
Searching about some case with issue, i found about it but the strategy behind clone is not clear.
I want understand how my pipeline works when clone is disabled, like this:
clone:
disable: true
steps:
- name: clone
image: alpine/git
commands:
- git clone https://github.com/my-org/my-repo.git .
- git fetch origin ${DRONE_SOURCE_BRANCH}
- git checkout ${DRONE_SOURCE_BRANCH}
and run analysis:
sonar-scanner \
-Dproject.settings=.sonarcloud.properties \
-Dsonar.login=$SONAR_REGISTRATION_LOGIN \
-Dsonar.qualitygate.wait=true \
-Dsonar.pullrequest.base=${DRONE_TARGET_BRANCH} \
-Dsonar.pullrequest.branch=${DRONE_SOURCE_BRANCH} \
-Dsonar.pullrequest.key=${DRONE_PULL_REQUEST} \
-Dsonar.pullrequest.provider=github
works:
but when try with image and checkout is via command not works
steps:
- name: composer
pull: if-not-exists
image: my-project-image.url
environment:
COMPOSER_AUTH:
from_secret: COMPOSER_AUTH
commands:
- git fetch origin ${DRONE_SOURCE_BRANCH}
- git checkout ${DRONE_SOURCE_BRANCH}
- ...