Brief overview:
- ALM used: Azure Devops
- CI system used: Azure DevOps
- Scanner command used when applicable: NA
- Languages of the repository: Python
- Error observed (Only occurred when being triggered by pull requests):
##[error]ERROR: Error during SonarScanner execution
ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
- Steps to reproduce:
- Setup branch policy to trigger static analysis pipeline upon pull requests
- Create a pull request to target branch
Detailed description:
Our pipeline suddenly encountered the mentioned error few days ago. No code or configuration was changed around the time of incident. We created the pipeline using yaml.
Here’s a snippet of our current pipeline, with removal of unrelated parts:
trigger: none
variables:
system_accesstoken: $(System.AccessToken)
jobs:
- job: PipelineName
pool:
vmImage: ubuntu-18.04
variables:
- group: sonar-variable-group
steps:
- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'sonarcloud_connection'
organization: $(ORGANIZATION)
scannerMode: CLI
configMode: manual
cliProjectKey: $(PROJECT_KEY)
cliProjectName: $(PROJECT_NAME)
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.exclusions=**/*.bin,**/*.json,**/*.yaml
sonar.python.coverage.reportPaths=modules/coverage.xml
- task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
- task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
The main twist is that the pipeline still works if triggered manually. PR-triggered pipeline will encounter mentioned error above.
Does anyone have any idea what happened?