we are trying to implement Sonar In our main branch
steps:
- task: DownloadBuildArtifacts@1
displayName: 'Download Build Artifacts'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
checkDownloadedFiles: true
- task: SonarQubePrepare@5
displayName: 'Prepare SonarQube Scan'
condition: succeeded()
inputs:
SonarQube: 'SonarQube TDC'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'Ace_Mail'
cliProjectName: '$(Build.Repository.Name)'
cliSources: '.'
extraProperties: |
sonar.branch.name=$(Build.SourceBranchName)
sonar.java.binaries=target
sonar.exclusions=**/*.xml,**/*.yml,**/*.css,**/*.js,**/*.html
- task: SonarQubeAnalyze@5
displayName: 'Run SonarQube Scan'
condition: succeeded()
- task: SonarQubePublish@5
displayName: 'Publish SonarQube Scan'
condition: succeeded()
inputs:
pollingTimeoutSec: '300'
it is throwing error as below
2023-10-10T15:37:24.5627441Z INFO: EXECUTION FAILURE
2023-10-10T15:37:24.5629467Z INFO: ------------------------------------------------------------------------
2023-10-10T15:37:24.5750220Z INFO: Total time: 2.671s
2023-10-10T15:37:24.5940164Z INFO: Final Memory: 6M/27M
2023-10-10T15:37:24.5973315Z ##[error]ERROR: Error during SonarScanner execution
ERROR: A pull request analysis cannot have the branch analysis parameter 'sonar.branch.name'
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
2023-10-10T15:37:24.5982403Z ERROR: Error during SonarScanner execution
2023-10-10T15:37:24.5982866Z ERROR: A pull request analysis cannot have the branch analysis parameter 'sonar.branch.name'
2023-10-10T15:37:24.5983218Z ERROR:
2023-10-10T15:37:24.5983545Z ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.