'Publishing test results in AzureDevops Hangs

We are using the Publish Test Results task PublishTestResults@2 to publish junit type results in a pipeline in Azure Devops. It has previously worked fine but is now hanging for 10mins (I think this is the default job timeout) and then failing, even though the results have been published. If I try to cancel the job when it starts hanging, the cancel request is ignored and the job continues to hang. Has anyone else experienced similar?

This is the log output whilst the task is hanging

Starting: PublishTestResults
==============================================================================
Task         : Publish Test Results
Description  : Publish test results to Azure Pipelines
Version      : 2.160.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/publish-test-results
==============================================================================
##[warning]An error occurred while sending the request.
Publishing test results to test run '1033544'.
TestResults To Publish 11, Test run id:1033544
Test results publishing 11, remaining: 0. Test run id: 1033544
Async Command Start: Publish test results


Solution 1:[1]

We eventually nailed this down to only occurring on agents running as a service, rather than interactively. The problem is that our agents are behind a proxy. We provided the proxy settings as per the instructions but it appears the Publish Test Results task doesn't use that settings, so we had to provide it to the environment that runs the service as well by editing runsvc.sh:

export HTTP_PROXY=http://ourproxy:8080/
export NO_PROXY=localhost,127.0.0.1,localaddress
export HTTPS_PROXY=http://ourproxy:8080/

Solution 2:[2]

Publishing test results in AzureDevops Hangs

According to the error message:

[warning]An error occurred while sending the request.

It shows that an error was encountered while sending the request, you could enable the debug log by changing the default variables system.debug to true.

If it worked fine previously and you haven't changed your build definition, then the problem should be caused by your network or Azure devops agent server. You could use private agent to check if it related to the hosted agent.

Besides, for the cancel request is ignored and the job continues to hang, you could set the Build job cancel timeout in minutes in the build options:

enter image description here

So, it won't hang your job all the time.

Hope this helps.

Solution 3:[3]

We had the same issue and it really looks like a proxy problem. Since we don't need result files uploaded, the following 'input' helped:

publishRunAttachments: false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ssloan
Solution 2 Leo Liu-MSFT
Solution 3 BuckTheBug