Reputation: 866
I am running sonar-scanner with help of sonarqube.yml this code code snippet from there
- name: Run sonarqube
run: sonar-scanner
-Dsonar.scm.provider=git
-Dsonar.login=${{ secrets.SONARQUBE_TOKEN }}
-Dsonar.pullrequest.key=${{ github.event.number }}
-Dsonar.pullrequest.branch=${GITHUB_HEAD_REF#refs/heads/}
-Dsonar.pullrequest.base=${GITHUB_BASE_REF#refs/heads/}
-Dsonar.pullrequest.github.repository=${GITHUB_REPOSITORY}
-Dsonar.pullrequest.github.endpoint=${GITHUB_API_URL}
Error after creating merge request
i see in executing log that is remaining -Dsonar.pullrequest.key= to be equal to undefined
Run sonar-scanner -Dsonar.scm.provider=git -Dsonar.login=*** -Dsonar.pullrequest.key= -Dsonar.pullrequest.branch=${GITHUB_HEAD_REF#refs/heads/} -Dsonar.pullrequest.base=${GITHUB_BASE_REF#refs/heads/} -Dsonar.pullrequest.github.repository=${GITHUB_REPOSITORY} -Dsonar.pullrequest.github.endpoint=${GITHUB_API_URL}
Upvotes: 3
Views: 7992
Reputation: 866
After merging branch to master it is commit and in that case ${{ github.event.number }} it's evaluating to null and it occures error so i suggest you to use in this case ${{github.sha}} even you can have condition
"-Dsonar.pullrequest.key=`if [ -z "${{github.event.number}}" ]; then echo ${{github.sha}}; else echo ${{github.event.number}}; fi`"
Upvotes: 2