Sonarqube Azure DevOps extension task Publish Quality Gate Result fails with new version 5.18.0

Sonarqube version 9.7.1
SonarScanner for MSBuild 5.14

##[error][SQ] Could not fetch metrics

##[error][SQ] API GET ‘/api/metrics/search’ failed, error is invalid json response body at https://sonarqube.skandianet.org/api/metrics/search?f=name&ps=500 reason: Unexpected token < in JSON at position 0

##[error][SQ] API GET ‘/api/ce/task’ failed, error is invalid json response body at https://sonarqube.skandianet.org/api/ce/task?id=AYvdDPyTuuZCtoYfFRii reason: Unexpected token < in JSON at position 0

##[error][SQ] Could not fetch task for ID ‘AYvdDPyTuuZCtoYfFRii’

1 Like

Hello @meanmfmachine , thank you for reaching out,

We need more information in order to help you, could you please:

  1. Run the pipeline in debug mode (With diagnostics logs) and send us the output

  2. Tell us whether you are using any kind of proxy or firewall to access SQ? And if yes, what your proxy configuration looks like (Azure agent running behind a proxy, HTTP(S)_PROXY env variable, firewall…)

  3. Verify that you are not mixing up task versions
    You should have

  • task: SonarQubePrepare@5
  • task: SonarQubeAnalyze@5
  • task: SonarQubePublish@5
  1. Tell us if the service connection that you set up for SQ using http or https?

  2. Tell us if you can access the page manually, eg (replace with your SQ)
    https://next.sonarqube.com/sonarqube/api/metrics/search

Thank you for your help

Hi, @benjamin.raymond!

We’ve been affected by this last update made to the “Publish Quality Gate Result” task as well.

In our case the errors are:

##[error][SQ] API GET '/api/metrics/search' failed, error is Invalid response body while trying to fetch http://sonar.xpto.br/api/metrics/search?f=name&ps=500: Premature close

##[error][SQ] API GET '/api/ce/task' failed, error is Invalid response body while trying to fetch http://sonar.xpto.br/api/ce/task?id=AYvdkun-AMdy9jUKxjR_: Premature close

##[error][SQ] Could not fetch task for ID 'AYvdkun-AMdy9jUKxjR_'

Complete log attached.
log-publish-task.txt (10.5 KB)

In this case the SonarQube server is on-premises and our Azure Pipelines self-hosted agent should use the proxy by pass to reach it.

This was working when using version 5.4.2 of this task.

More info:

SonarScanner 4.8.1.3023 (scan step completes succesfully)
SonarQube 9.9

Best Regards

Thanks!

2 Likes

Hello @meanmfmachine and @mrinardo ,

We just released version 5.18.2 of the extension. Could you please let me know if it fixed your issue?

Thank you for your debug logs @mrinardo , it was really helpful to find the root cause.

1 Like

We are also experiencing similar issues using SonarQbe ADO task v5.18.0 - 5.18.2. The tasks used to work with no additional proxy setup required.

SonarQubePrepare task fails with
##[error][SQ] API GET ‘/api/server/version’ failed, error is Response timeout while trying to fetch …
This can be fixed by https proxy setting through SONAR_SCANNER_OPTS

SonarQubeAnalyze task works with only without the proxy settings, so no SONAR_SCANNER_OPTS. Otherwise it can’t reach the server.

SonarQubePublish doesn’t work with or without the proxy setting. It always fails with:
##[error][SQ] API GET ‘/api/metrics/search’ failed, error is Response timeout
##[error][SQ] API GET ‘/api/server/version’ failed, error is Response timeout

This is a major blocker for our team, I believe more teams working behind corporate proxies are also affected.

@Michal_Chudziak : can you please attach the DEBUG logs (sonar.verbose=true) for us to review? This will help us check what corrections will be needed.

sonar.txt (42.6 KB)
logs.txt (156.8 KB)

We are also affected by this update.Our pipelines are failing with the attached error.
Sonarqube version: Community Edition Version 9.9
SonarScanner for MsBuild 5.14

Hi team, we are using SonarQube v10.2.1 and we also encountered a similar issue. Can you please assist? Thanks

##[debug][SQ] Task status:PENDING
##[debug][SQ] Waiting for task 'AYvrVIW9aqLrN4rOFAIA' to complete.
##[debug][SQ] API GET: '/api/ce/task' with full URL "{companyurl}/api/ce/task?id=AYvrVIW9aqLrN4rOFAIA" and query "{"id":"AYvrVIW9aqLrN4rOFAIA"}"
##[debug]Agent.ProxyUrl=undefined
##[debug]Not using a proxy agent
##[debug][SQ] API GET '/api/ce/task' failed, error is Invalid response body while trying to fetch {companyurl}/api/ce/task?id=AYvrVIW9aqLrN4rOFAIA: Premature close
##[error][SQ] API GET '/api/ce/task' failed, error is Invalid response body while trying to fetch {companyurl}/api/ce/task?id=AYvrVIW9aqLrN4rOFAIA: Premature close
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/ce/task' failed, error is Invalid response body while trying to fetch {companyurl}/api/ce/task?id=AYvrVIW9aqLrN4rOFAIA: Premature close
##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AYvrVIW9aqLrN4rOFAIA'
##[debug]task result: Failed
##[error][SQ] Could not fetch task for ID 'AYvrVIW9aqLrN4rOFAIA'
##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch task for ID 'AYvrVIW9aqLrN4rOFAIA'
##[debug]Processed: ##vso[task.complete result=Failed;][SQ] Could not fetch task for ID 'AYvrVIW9aqLrN4rOFAIA'

Hello @PatrickAngrezani , @mrinardo @Michal_Chudziak @KennyRogers @elliechen

We are actively working on releasing a version that addresses your issues,

However, we are having trouble reproducing your issues, which makes us believe there is something different between our testing environment and yours,

We would need to know:

  1. How are you passing proxy configuration to the agent?
    Is it through HTTP_PROXY, HTTPS_PROXY, both? Is your SQ reached through http or https? (If it is http, HTTP_PROXY should be set, if it is https, HTTPS_PROXY should be set). Are you using the NO_PROXY environment variable?

  2. We need the diagnostics logs for the Prepare, Analyze and Publish tasks
    You can generate these logs by:

    • Navigating on the pipeline
    • Clicking “Run pipeline” and tick the “Enable system diagnostics” checkbox at the bottom of the side panel which should open
    • Actually run the pipeline
    • You can download logs and send them to us

In the meantime, even though that is not optimal, you may want to temporarily disable the publish step from your pipeline while we publish a new patch release,

Thank you a lot for your help

2 Likes

Hello @PatrickAngrezani @mrinardo @Michal_Chudziak @KennyRogers @elliechen

We were able to reproduce your failure in specific setups where proxy variables were not always set: For instance, if you are reaching an https SQ through a proxy and you are only passing HTTP_PROXY, not HTTPS_PROXY.

We just released 5.18.3 which we hope will fix your issue. If after this you still encounter issues, please refer to my previous message to help us dig into it,

Thank you for your help and your patience

2 Likes

Hello Benjamin Raymond,

The issue still persist for us.
Please find attached the logs for the Prepare Stage.

sonar.txt (23.4 KB)

Hello Benjamin Raymond and team,

Upon a rerun of the same pipeline, the prepare stage succeeded but now it failed on the analysis stage.
Please find attached the logs for the analyse stage.

sonar1.txt (257.4 KB)

Thanks for your support and we look forward to your assistance.

Hi, @benjamin.raymond!

Versions 5.18.2 and 5.18.3 seem to work fine for us.

Our Azure DevOps agents are running behind a proxy and our SonarQube server is hosted on-premises (currently being accessed by Azure DevOps agents with HTTP).

After the original breaking change made to the Publish task (and its subsequent fixes) it was required for us to add our SonarQube endpoint in the agents’ .proxybypass files in order for the Publish task to communicate properly with it.

One thing strange I noticed in the last version was that it prints “##[debug]Not using a proxy agent” in the Publish task, even when we had not inserted our on-prem SonarQube’s URL in the Azure DevOps agent’s .proxybypass file…

Thanks!

Best Regards

4 Likes

Hello @KennyRogers , your failure does not seem related to our update. If you have timeout issues, you may want to consider adding sonar.ws.timeout to the extra properties of the prepare task

@mrinardo , happy to hear that your issue was resolved

it prints “##[debug]Not using a proxy agent ” in the Publish task, even when we had not inserted our on-prem SonarQube’s URL in the Azure DevOps agent’s .proxybypass file…

We no longer read Azure proxy configuration to make requests (technically, that is recommended by Azure, but in order to keep compatibility with <5.18, we choosed to revert this change). So, the .proxybypass file should have no effect on whether the proxy is used within the extension.

Cheers

2 Likes