Sonarqube with Azure DevOps Publish Quality Gate Task Result fails

Hi Sonar Team,
SonarQube version 9.9.3 LTS Community
Sonar plugin for azure devops 5.19.0

we are facing the Issue with SonarQube publish quality gates is fails from azure hosted agent and Azure cloud VM along with self hosted agent is getting failed if we are using private self hosted agent in our own on-premises agent its working fine , pls find below failed the logs

2024-02-08T05:25:09.3417853Z ##[section]Starting: Publish Quality Gate Result
2024-02-08T05:25:09.3575919Z ==============================================================================
2024-02-08T05:25:09.3576089Z Task : Publish Quality Gate Result
2024-02-08T05:25:09.3576167Z Description : Publish SonarQube’s Quality Gate result on the Azure DevOps build result, to be used after the actual analysis.
2024-02-08T05:25:09.3576334Z Version : 5.6.0
2024-02-08T05:25:09.3576396Z Author : sonarsource
2024-02-08T05:25:09.3576461Z Help : Version: 5.6.0. More Information
2024-02-08T05:25:09.3576599Z ==============================================================================
2024-02-08T05:25:10.1851307Z ##[error][SQ] API GET ‘/api/metrics/search’ failed, error is invalid json response body at reason: Unexpected token < in JSON at position 0
2024-02-08T05:25:10.1854845Z ##[error]Could not fetch metrics
2024-02-08T05:25:10.1888430Z ##[section]Finishing: Publish Quality Gate Result

publish Quality task working for private self hosted on-premises is build completing successfully below the logs

2024-02-08T06:28:07.2013309Z ##[section]Starting: Publish Quality Gate Result
2024-02-08T06:28:07.2506613Z ==============================================================================
2024-02-08T06:28:07.2506920Z Task : Publish Quality Gate Result
2024-02-08T06:28:07.2507094Z Description : Publish SonarQube’s Quality Gate result on the Azure DevOps build result, to be used after the actual analysis.
2024-02-08T06:28:07.2507837Z Version : 5.6.0
2024-02-08T06:28:07.2507921Z Author : sonarsource
2024-02-08T06:28:07.2508025Z Help : Version: 5.6.0. More Information
2024-02-08T06:28:07.2508528Z ==============================================================================
2024-02-08T06:28:16.8133508Z ##[section]Finishing: Publish Quality Gate Result

Seems like this URL isn’t returning the expected results:

What is the response you get if you query this URL directly from the agent? You can use something like curl or Invoke-WebRequest do this this during your build.

HI @Colin

Thank you for reply.

Please find the logs attached by using the invoke-web-request job from the agent.
sonarlogs.txt (13.3 KB)

I see the word “challenge” a lot in the web request. Is there something sitting in front of your SonarQube server that has to be authenticated against before you can access SonarQube?

HI @Colin

Pls find the below the attached pictograph of infra to better understand

We are using for on-premises machine is using for self-hosted agent at that time the build is completing succuss.
Here also adding invoke-webrequest log from on-premises agent.
invoke-webrequest.txt (760 Bytes)

Is the rest of your build successful? Meaning, before Publish Quality Gate Result, an analysis is successfully submitted to SonarQube?



Yes before, publish quality gate results the analysis task is completing successfully and submitted to sonarqube server


The Publish Quality Gate Result step uses NodeJS – as opposed to other tasks which use either Java / .NET.

Perhaps some proxy information needs to be passed to HTTP_PROXY/HTTPS_PROXY environment variables? I’m not that experienced with Cloudflare and what might be happening before the request hits your SonarQube server.

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