Quality Gate Status Never Received, Azure DevOps

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Languages of the repository (C#)

We have a pipeline triggered via the creation of a pull request that then invokes a second pipeline in a separate ADO project (passing through a number of variables from the triggering pipeline)

Our project is bound within Sonar (configured as a Mono repo), and we have a valid project-level PAT token (with read and write permissions).

PR Decoration appears to be working and the pipeline job is updated with the output of the scan

However, the quality gate status is never sent back to the PR

I’ve also checked the ADO API

https://dev.azure.com/ORG/PROJECT/_apis/git/repositories/REPO/pullRequests/PRID/statuses?api-version=7.1

and there are no status updates from Sonar.

Within the prepare task we are setting the following;

          projectKey
          projectName
          sonar.cs.vscoveragexml.reportsPathsl
          sonar.sources=src
          sonar.tests=tests
          sonar.exclusions
          sonar.coverage.exclusions
          sonar.pullrequest.key
          sonar.pullrequest.branch
          sonar.pullrequest.base

Is there any additional logging I could enable to investigate this?

If it helps, here is the background task id from Sonar; as far as I can tell everything is working, except for the missing quality gate status

Project Analysis

ID: AZJJLn0GcGOSx8pIQrM8

Hi,

Welcome to the community!

Is there any way you can trigger this again? Very often, these seem to be transient errors on the DevOps Platform side.

 
Ann

1 Like

Absolutely… done, here is the new analysis ID.

Analysis ID: AZJTHJOVvxW-ElunCjs8

Looking at the ADO, API, there are no sonar quality gates created against the pr.

I feel like everything is working; it is just that the server is not publishing the quality gate back to ADO and the pr. :frowning:

Is there anyway to check on Sonar if it is attempting the API call back to ADO to set the quality gate status?

Hi,

Thanks for checking. I’ve flagged this for the team.

 
Ann

1 Like

Hi @PaulD

We checked server logs, and there is indeed an issue while trying to set the status back to the PR.

It seems our service is unable to get the project name and repository slug to decorate. You said that the project is correctly bound. Would you mind double-checking?
Also, if you don’t have an analysis history on this project, you could try deleting it in SonarCloud and importing it again.

1 Like

HI, thanks for getting back to me :slight_smile: :smile: Sorry for the delays.

See below, but unfortunately that has not helped and the status is still not being published from the Sonar Server to ADO.

I’ve removed the project, readded and rescanned, within sonar the project shows as bound

image

I also made sure that the main branch has been scanned a few times.

Analysis ID: AZJmcKnso4E76o_EtrSB

thanks for any help you can provide. - PD.

In case it helps at all, we have also replaced the ADO pat token and rebound, just in case that was causing an issue. Please let me know if there is anything further I can investigate to help solve the issue.

Hey @PaulD ,

I suspect that the second pipeline does not have full information for the Quality Gate report to happen. The Azure prepare task is setting some variables, as seen here, and when you execute it on the second pipeline, which is not in the PR context, it cannot read that info.

In short, I think you might need to pass those variables to your second pipeline:

sonar.pullrequest.vsts.instanceUrl
sonar.pullrequest.vsts.project
sonar.pullrequest.vsts.repository

In any case, what’s the reason for having a different pipeline executed? Why not have PR decoration on the same pipeline as your repository?

I think what you could try is to execute the prepare task in your first pipeline and then pass all properties and ENV variables to the second pipeline as is and execute other tasks.

1 Like

Hi Jack, thanks for getting back to me. The first pipeline acts as a trigger to the second; so the prepare, analysis and publish all happen on the second pipeline. I’d have to investigate into if its an open to add the prepare to the trigger pipeline.

I did try passing those arguments prior to raising the ticket, but let me retry. I was hoping that as the project is bound directly to the repo in ADO, passing the vtsts details would not be necessary.

Let me update the params, and retest. Thanks for the advice; watch this space.

2 Likes

PS, just a quick follow-up question: Do I have to worry about any spaces being escaped in project name?

I think it should be fine

1 Like

H, Jacek,

So, I’ve followed your advice and set the additional properties; however, we are still not getting back a quality gate status to the ado pr.

See a snapshot from background task context.

Looking at the sonar report, it seems like everything executed as expected.

image

(minus the quality gate status update in ADO).

I’ve also tried updating the project pat tokens and the org pat token (both have code, read, and write).

Can you see anything on the sonar cloud server side for the analysis?

Project Analysis

ID: AZKSA7VpARBLK1vu-8Jh

PS Just a reminder, this is configured as a mono repo, with two projects, and the project name contains spaces.

1 Like

Hey @PaulD ,

I found logs on our backend, and it seems like the parameters have been passed, but apparently, the decoration failed when trying to get the commit - I feel we are close :slight_smile:

Is your second pipeline executed on another repository? Could revisions be different? If yes, could you try adding the following property, sonar.scm.revision, with the sha of the latest commit from original PR?

I’ve sent you a private message in which the call to Azure failed, so that you can confirm with me if parameters are correct.

1 Like

Hi Jacek,thanks for getting back to me, I think the answer is yes that could be the issue, let me check it out and I’ll get back to you asap.

1 Like

Fantastic news, This appears to have sorted the problem, are there any other properties I should be looking at in addition.

Thank you so much for your help on this, Im still testing (passed is working though, so I’ve very happy).

  • Paul.
2 Likes

Hey @PaulD ,

I don’t think so, though if anything comes up, don’t hesitate to ask for help here :smile:

1 Like

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