PR status check and decoration not working

Dear team,

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
    Azure DevOps

  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI)
    Azure DevOps

  • Scanner command used when applicable (private details masked)
    Generic scanner on Azure Pipelines

  • Languages of the repository
    C# / dotnet 3.1 / xUnit

  • Only if the SonarCloud project is public, the URL

    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    PR requests are getting analysed by SonarCloud, however no PR decoration information is being post back to Azure DevOps.
    The “SonarCloud/quality gate” is not being show as a dropdown option in the “Require approval from additional services”. Only the codecoverage status from Azure DevOps is being shown.

  • Steps to reproduce

  1. Repository in Azure DevOps
  2. Branch Policy
  • Require a minimum number of reviewers - Checked
  • Minimum number of reviewers - 2
  • Reset code reviewer votes when there are new changes - Checked
  • Check for linked work items - Optional
  • Check for comment resolution - Required
  • Limit Merge Types - Basic, Squash, Rebase
  1. Build Validation Policy
  • Trigger - Automatic
  • Policy Requirement - Required
  • Expiration - 12 hours
  1. Personal Access Token
  • Code (Read & Write)
  • Expire 2020/06/07
  1. SonarCloud Settings
    Project > Administration > General Settings > Pull Request
    sonar.pullrequest.provider : Azure DevOps Services
    sonar.pullrequest.vsts.token.secured : PAT token as specified above

We could not unfortunately activate this for any of our projects. We are not sure if this is an issue with DevOps, SonarCloud, configuration or our account. We have tried various suggestions from blogs and the SonarSource community posts to no avail.

Best,
Andrew Broekman

Hi @andrewbroekman and welcome to the community !

Do you see any warning when going to the dashboard of the PR on SonarCloud (at the top right corner) ?

Can you please go to the Administration -> Background tasks page of the project and give me one task id

image

So i can have a look at our internal logs.

Thanks in advance.

Good morning Mickaël,

I don’t see any warning when I go to a PR. I either see passed or failed depending if the PR satisfied the Quality Gate requirements we setup.

Herewith as requested a task ID: AXH3yj15-U-4l98ARPRp

Thanks in advance.

Hi,

Thanks. Could you please give me a date/time on when this task has been processed ?

Hi,

Please find attached as requested.

Please note that PR-184 has been closed on our side.
Task: A*****/E*****/PR-184
ID: AXH3yj15-U-4l98ARPRp
Date: May 9, 2020
Submitted: 6:55:58 AM

The task below is of a current open PR we are trying to decorate.
Task: A*****/E*****/PR-187
ID: AXH0YSQwuo7p7bNgY-46
Date: May 9, 2020
Submitted: 3:02:19 PM

Thanks.

Are you overriding by yourself, by any chance, the System.PullRequest.PullRequestId or System.PullRequest.PullRequestNumber properties ?

Yes we do overwrite them. Herewith the Azure DevOps task that we are using:

- task: SonarCloudPrepare@1
  displayName: 'Prepare Analysis on SonarQube for Pull Request'
  condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
  inputs:
    SonarCloud: REDACTED
    organization: REDACTED
    scannerMode: 'MSBuild'
    projectKey: REDACTED
    projectName: REDACTED
    extraProperties: |
      sonar.pullrequest.key=PR-$(System.PullRequest.PullRequestId)
      sonar.pullrequest.branch=$(Build.SourceBranchName)
      sonar.cs.vstest.reportsPaths=REDACTED
      sonar.cs.opencover.reportsPaths=REDACTED
      sonar.exclusions=REDACTED

Thanks.

Please note that this is not supported (it will not find the correct PR to decorate), and this field only accept numeric values.

Those 2 properties :
sonar.pullrequest.key=PR-(System.PullRequest.PullRequestId) sonar.pullrequest.branch=(Build.SourceBranchName)

Are automatically filled for you, you don’t have to worry about them, so you can safely remove those from extraProperties.

Good evening Mickaël,

Thank you for the assistance, that has solved the problem; I will remember for future :slight_smile:

Regards.
Andrew

1 Like

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