SonarCloud/quality gate is waiting forever in Azure Devops Pull Requests

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Scanner command used when applicable (private details masked)
- task: SonarCloudPrepare@3
  displayName: 'SonarCloud - Prepare Analysis Configuration (pre-build)'
  inputs:
    SonarCloud: 'SonarCloud - ${{ parameters.projectName }}'
    organization: '***'
    scannerMode: 'dotnet'
    projectKey: '***'
    projectName: '***'
    extraProperties: |
      sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
      sonar.cs.opencover.reportsPaths = $(Agent.TempDirectory)/**/coverage.opencover.xml
      sonar.verbose=true

- task: SonarCloudAnalyze@3
  displayName: 'SonarCloud - Run Code Analysis (post-build)'
            
- task: SonarCloudPublish@3
  displayName: 'sonarcloud - publish quality gate result in PR'
  condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
  inputs:
    pollingTimeoutSec: '300'

We use this scanner command template for multiple projects/repositories and it works for all except this project. It used to work for this project also, but the latest successful run was in the beginning of December 2024.
In SonarCloud, we see the code analysis being run successfully, but somehow the result is never shown in the Azure DevOps PR.

We do see a weird warning in the analysis though:
Could not find ref 'master' in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.
But we did see this warning in the latest successful run also.

Also, the service connection is valid.

Any idea how to solve this issue?

Hi,

Do you have a PAT set at the project level? If so, it’s quite possible it’s expired. You could replace it with a new one, or just remove it to fall back to the apparently-valid organization-level PAT.

 
HTH,
Ann

Thanks a lot. Somehow there was a PAT set just for this project, we’ve reset this settings and now it works flawlessly.

For future reference, this was the setting which was set and now reset:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.