Publish Quality Gate Result error on some builds but the same agent

We use SonarCloud to perform analysis of several projects in one organization. The code and build pipelines are stored in Azure DevOps (dev.azure.com). We use the latest available task versions to integrate with SonarCloud:

  • Prepare Analysis Configuration 1.18.0
  • Run Code Analysis 1.21.0
  • Publish Quality Gate Result 1.10.1

We have an agent hosted within corporate network and use proxy to connect to SonarCloud.

The problem we have is that one of the build analysis succeed but the other with the same task configuration fails to publish quality gate result. The analysis is performed successfully and the gate is calculated in Sonar. Both builds were executed on the same agent, so it’s not agent configuration dependent.

I post below the logs from the successful and failing builds for comparison.

##[debug]Evaluating: succeeded()
##[debug]Evaluating succeeded:
##[debug]=> True
##[debug]Result: True
##[section]Starting: Publish Quality Gate Result
==============================================================================
Task         : Publish Quality Gate Result
Description  : Publish SonarCloud's Quality Gate result on the Azure Pipelines build result. To be used after the actual analysis.
Version      : 1.10.1
Author       : sonarsource
Help         : Version: 1.10.1. [More Information](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
==============================================================================
##[debug]Using node path: D:\Agents\S4\externals\node\bin\node.exe
##[debug]agent.TempDirectory=D:\Agents\S4\_work\_temp
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_POLLINGTIMEOUTSEC
##[debug]loading SECRET_SONARQUBE_ENDPOINT
##[debug]loaded 5
##[debug]Agent.ProxyUrl=http://proxy:8082
##[debug]Agent.ProxyUsername=undefined
##[debug]Agent.ProxyPassword=undefined
##[debug]Agent.ProxyBypassList=undefined
##[debug]expose agent proxy configuration.
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io/","sonar.login":***,"sonar.organization":"xxx","sonar.projectKey":"yyy","sonar.projectName":"YYY","sonar.projectVersion":"1.0.171","sonar.scanner.metadataFilePath":"D:\\Agents\\S4\\_work\\_temp\\sonar\\1.0.171\\f2d53aa0-c7f0-1b27-7649-27065bd41dbc\\report-task.txt","sonar.c.file.suffixes":"-","sonar.cpp.file.suffixes":"-","sonar.objc.file.suffixes":"-"}
##[debug]SONARQUBE_ENDPOINT=***
##[debug][SQ] API GET: '/api/metrics/search' with query "{"f":"name","ps":500}"
##[debug]Response: 200 Body: "{"metrics":[{"id":"289","key":"new_technical_debt","type":"WORK_DUR","name":"Added Technical Debt"},{"id":"78","key":"blocker_violations","type":"INT","name":"Blocker Issues"},{"id":"308","key":"bugs","type":"INT","name":"Bugs"},{"id":"4","key":"classes","type":"INT","name":"Classes"},{"id":"306","key":"code_smells","type":"INT","name":"Code Smells"},{"id":"347","key":"cognitive_complexity","type":"INT","name":"Cognitive Complexity"},{"id":"32","key":"comment_lines","type":"INT","name":"Comment Lines"},{"id":"239","key":"comment_lines_data","type":"DATA","name":"comment_lines_data"},{"id":"33","key":"comment_lines_density","type":"PERCENT","name":"Comments (%)"},{"id":"27","key":"class_complexity","type":"FLOAT","name":"Complexity / Class"},{"id":"38","key":"file_complexity","type":"FLOAT","name":"Complexity / File"},{"id":"28","key":"function_complexity","type":"FLOAT","name":"Complexity / Function"},{"id":"272","key":"complexity_in_classes","type":"INT","name":"Complexity in Classes"},{"id":"273","key":"complexity_in_functions","type":"INT","name":"Complexity in Functions"},{"id":"97","key":"branch_coverage","type":"PERCENT","name":"Condition Coverage"},{"id":"178","key":"new_branch_coverage","type":"PERCENT","name":"Condition Coverage on New Code"},{"id":"95","key":"conditions_to_cover","type":"INT","name":"Conditions to Cover"},{"id":"176","key":"new_conditions_to_cover","type":"INT","name":"Conditions to Cover on New Code"},{"id":"277","key":"confirmed_issues","type":"INT","name":"Confirmed Issues"},{"id":"20","key":"coverage","type":"PERCENT","name":"Coverage"},{"id":"172","key":"new_coverage","type":"PERCENT","name":"Coverage on New Code"},{"id":"79","key":"critical_violations","type":"INT","name":"Critical Issues"},{"id":"26","key":"complexity","type":"INT","name":"Cyclomatic Complexity"},{"id":"181","key":"last_commit_date","type":"MILLISEC","name":"Date of Last Commit"},{"id":"280","key":"development_cost","type":"STRING","name":"Development Cost"},{"id":"348","key":"new_development_cost","type":"FLOAT","name":"Development Cost on New Code"},{"id":"37","key":"directories","type":"INT","name":"Directories"},{"id":"51","key":"duplicated_blocks","type":"INT","name":"Duplicated Blocks"},{"id":"339","key":"new_duplicated_blocks","type":"INT","name":"Duplicated Blocks on New Code"},{"id":"52","key":"duplicated_files","type":"INT","name":"Duplicated Files"},{"id":"8","key":"duplicated_lines","type":"INT","name":"Duplicated Lines"},{"id":"34","key":"duplicated_lines_density","type":"PERCENT","name":"Duplicated Lines (%)"},{"id":"340","key":"new_duplicated_lines_density","type":"PERCENT","name":"Duplicated Lines (%) on New Code"},{"id":"338","key":"new_duplicated_lines","type":"INT","name":"Duplicated Lines on New Code"},{"id":"53","key":"duplications_data","type":"DATA","name":"Duplication Details"},{"id":"312","key":"effort_to_reach_maintainability_rating_a","type":"WORK_DUR","name":"Effort to Reach Maintainability Rating A"},{"id":"321","key":"executable_lines_data","type":"DATA","name":"executable_lines_data"},{"id":"274","key":"false_positive_issues","type":"INT","name":"False Positive Issues"},{"id":"154","key":"file_complexity_distribution","type":"DISTRIB","name":"File Distribution / Complexity"},{"id":"36","key":"files","type":"INT","name":"Files"},{"id":"59","key":"function_complexity_distribution","type":"DISTRIB","name":"Function Distribution / Complexity"},{"id":"6","key":"functions","type":"INT","name":"Functions"},{"id":"150","key":"generated_lines","type":"INT","name":"Generated Lines"},{"id":"151","key":"generated_ncloc","type":"INT","name":"Generated Lines of Code"},{"id":"82","key":"info_violations","type":"INT","name":"Info Issues"},{"id":"42","key":"violations","type":"INT","name":"Issues"},{"id":"94","key":"line_coverage","type":"PERCENT","name":"Line Coverage"},{"id":"175","key":"new_line_coverage","type":"PERCENT","name":"Line Coverage on New Code"},{"id":"55","key":"lines","type":"INT","name":"Lines"},{"id":"5","key":"ncloc","type":"INT","name":"Lines of Code"},{"id":"293","key":"ncloc_language_distribution","type":"DATA","name":"Lines of Code Per Language"},{"id":"92","key":"lines_to_cover","type":"INT","name":"Lines to Cover"},{"id":"173","key":"new_lines_to_cover","type":"INT","name":"Lines to Cover on New Code"},{"id":"163","key":"sqale_rating","type":"RATING","name":"Maintainability Rating"},{"id":"341","key":"new_maintainability_rating","type":"RATING","name":"Maintainability Rating on New Code"},{"id":"80","key":"major_violations","type":"INT","name":"Major Issues"},{"id":"81","key":"minor_violations","type":"INT","name":"Minor Issues"},{"id":"238","key":"ncloc_data","type":"DATA","name":"ncloc_data"},{"id":"165","key":"new_blocker_violations","type":"INT","name":"New Blocker Issues"},{"id":"309","key":"new_bugs","type":"INT","name":"New Bugs"},{"id":"307","key":"new_code_smells","type":"INT","name":"New Code Smells"},{"id":"166","key":"new_critical_violations","type":"INT","name":"New Critical Issues"},{"id":"169","key":"new_info_violations","type":"INT","name":"New Info Issues"},{"id":"164","key":"new_violations","type":"INT","name":"New Issues"},{"id":"337","key":"new_lines","type":"INT","name":"New Lines"},{"id":"167","key":"new_major_violations","type":"INT","name":"New Major Issues"},{"id":"168","key":"new_minor_violations","type":"INT","name":"New Minor Issues"},{"id":"351","key":"new_security_hotspots","type":"INT","name":"New Security Hotspots"},{"id":"311","key":"new_vulnerabilities","type":"INT","name":"New Vulnerabilities"},{"id":"275","key":"open_issues","type":"INT","name":"Open Issues"},{"id":"47","key":"quality_profiles","type":"DATA","name":"Profiles"},{"id":"240","key":"projects","type":"INT","name":"Projects"},{"id":"58","key":"public_api","type":"INT","name":"Public API"},{"id":"61","key":"public_documented_api_density","type":"PERCENT","name":"Public Documented API (%)"},{"id":"62","key":"public_undocumented_api","type":"INT","name":"Public Undocumented API"},{"id":"294","key":"quality_gate_details","type":"DATA","name":"Quality Gate Details"},{"id":"48","key":"alert_status","type":"LEVEL","name":"Quality Gate Status"},{"id":"315","key":"reliability_rating","type":"RATING","name":"Reliability Rating"},{"id":"342","key":"new_reliability_rating","type":"RATING","name":"Reliability Rating on New Code"},{"id":"313","key":"reliability_remediation_effort","type":"WORK_DUR","name":"Reliability Remediation Effort"},{"id":"314","key":"new_reliability_remediation_effort","type":"WORK_DUR","name":"Reliability Remediation Effort on New Code"},{"id":"276","key":"reopened_issues","type":"INT","name":"Reopened Issues"},{"id":"350","key":"security_hotspots","type":"INT","name":"Security Hotspots"},{"id":"354","key":"security_hotspots_reviewed","type":"PERCENT","name":"Security Hotspots Reviewed"},{"id":"355","key":"new_security_hotspots_reviewed","type":"PERCENT","name":"Security Hotspots Reviewed on New Code"},{"id":"319","key":"security_rating","type":"RATING","name":"Security Rating"},{"id":"343","key":"new_security_rating","type":"RATING","name":"Security Rating on New Code"},{"id":"317","key":"security_remediation_effort","type":"WORK_DUR","name":"Security Remediation Effort"},{"id":"318","key":"new_security_remediation_effort","type":"WORK_DUR","name":"Security Remediation Effort on New Code"},{"id":"352","key":"security_review_rating","type":"RATING","name":"Security Review Rating"},{"id":"353","key":"new_security_review_rating","type":"RATING","name":"Security Review Rating on New Code"},{"id":"356","key":"security_hotspots_reviewed_status","type":"INT","name":"Security Review Reviewed Status"},{"id":"358","key":"new_security_hotspots_reviewed_status","type":"INT","name":"Security Review Reviewed Status on New Code"},{"id":"357","key":"security_hotspots_to_review_status","type":"INT","name":"Security Review To Review Status"},{"id":"359","key":"new_security_hotspots_to_review_status","type":"INT","name":"Security Review To Review Status on New Code"},{"id":"11","key":"skipped_tests","type":"INT","name":"Skipped Unit Tests"},{"id":"60","key":"statements","type":"INT","name":"Statements"},{"id":"162","key":"sqale_index","type":"WORK_DUR","name":"Technical Debt"},{"id":"297","key":"sqale_debt_ratio","type":"PERCENT","name":"Technical Debt Ratio"},{"id":"304","key":"new_sqale_debt_ratio","type":"PERCENT","name":"Technical Debt Ratio on New Code"},{"id":"96","key":"uncovered_conditions","type":"INT","name":"Uncovered Conditions"},{"id":"177","key":"new_uncovered_conditions","type":"INT","name":"Uncovered Conditions on New Code"},{"id":"93","key":"uncovered_lines","type":"INT","name":"Uncovered Lines"},{"id":"174","key":"new_uncovered_lines","type":"INT","name":"Uncovered Lines on New Code"},{"id":"14","key":"test_execution_time","type":"MILLISEC","name":"Unit Test Duration"},{"id":"10","key":"test_errors","type":"INT","name":"Unit Test Errors"},{"id":"12","key":"test_failures","type":"INT","name":"Unit Test Failures"},{"id":"13","key":"tests","type":"INT","name":"Unit Tests"},{"id":"15","key":"test_success_density","type":"PERCENT","name":"Unit Test Success (%)"},{"id":"310","key":"vulnerabilities","type":"INT","name":"Vulnerabilities"},{"id":"324","key":"wont_fix_issues","type":"INT","name":"Won't Fix Issues"}],"total":111,"p":1,"ps":500}"
##[debug]pollingTimeoutSec=300
##[debug][SQ] API GET: '/api/server/version' with query "undefined"
##[debug]Response: 200 Body: "8.0.0.19383"
##[debug]Build.BuildNumber=1.0.171
##[debug]Agent.TempDirectory=D:\Agents\S4\_work\_temp
##[debug]defaultRoot: 'D:\Agents\S4\_work\_temp'
##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug]matchOptions.debug: 'false'
##[debug]matchOptions.nobrace: 'true'
##[debug]matchOptions.noglobstar: 'false'
##[debug]matchOptions.dot: 'true'
##[debug]matchOptions.noext: 'false'
##[debug]matchOptions.nocase: 'true'
##[debug]matchOptions.nonull: 'false'
##[debug]matchOptions.matchBase: 'false'
##[debug]matchOptions.nocomment: 'false'
##[debug]matchOptions.nonegate: 'false'
##[debug]matchOptions.flipNegate: 'false'
##[debug]pattern: 'sonar\1.0.171\**\report-task.txt'
##[debug]findPath: 'D:\Agents\S4\_work\_temp\sonar\1.0.171'
##[debug]statOnly: 'false'
##[debug]findPath: 'D:\Agents\S4\_work\_temp\sonar\1.0.171'
##[debug]findOptions.allowBrokenSymbolicLinks: 'false'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug]  D:\Agents\S4\_work\_temp\sonar\1.0.171 (directory)
##[debug]  D:\Agents\S4\_work\_temp\sonar\1.0.171\f2d53aa0-c7f0-1b27-7649-27065bd41dbc (directory)
##[debug]  D:\Agents\S4\_work\_temp\sonar\1.0.171\f2d53aa0-c7f0-1b27-7649-27065bd41dbc\report-task.txt (file)
##[debug]3 results
##[debug]found 3 paths
##[debug]applying include pattern
##[debug]adjustedPattern: 'D:\Agents\S4\_work\_temp\sonar\1.0.171\**\report-task.txt'
##[debug]1 matches
##[debug]1 final results
##[debug][SQ] Searching for sonar\1.0.171\**\report-task.txt - found 1 file(s)
##[debug][SQ] Read Task report file: D:\Agents\S4\_work\_temp\sonar\1.0.171\f2d53aa0-c7f0-1b27-7649-27065bd41dbc\report-task.txt
##[debug][SQ] Parse Task report file: organization=xxx
projectKey=xxx
serverUrl=https://sonarcloud.io
serverVersion=8.0.0.19383
dashboardUrl=https://sonarcloud.io/dashboard?id=yyy
ceTaskId=AXjuA9zY2VwZVNg7RrQX
ceTaskUrl=https://sonarcloud.io/api/ce/task?id=AXjuA9zY2VwZVNg7RrQX

##[debug][SQ] Waiting for task 'AXjuA9zY2VwZVNg7RrQX' to complete.
##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXjuA9zY2VwZVNg7RrQX","additionalFields":"warnings"}"
##[debug]Response: 200 Body: "{"task":{"id":"AXjuA9zY2VwZVNg7RrQX","type":"REPORT","componentId":"AXRzVPVh4ZjJ5vIqQ-A6","componentKey":"xxx","componentName":"XXX","componentQualifier":"TRK","analysisId":"AXjuA9_Aj96QugIjm7y0","status":"SUCCESS","submittedAt":"2021-04-20T08:42:14+0200","submitterLogin":"adam-zamojski58056","startedAt":"2021-04-20T08:42:14+0200","executedAt":"2021-04-20T08:42:21+0200","executionTimeMs":7012,"logs":false,"hasScannerContext":true,"organization":"cdsng","warningCount":1,"warnings":["Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone."]}}"
##[debug][SQ] Task status:SUCCESS
##[debug][SQ] Task complete: {"id":"AXjuA9zY2VwZVNg7RrQX","type":"REPORT","componentId":"AXRzVPVh4ZjJ5vIqQ-A6","componentKey":"xxx","componentName":"XXX","componentQualifier":"TRK","analysisId":"AXjuA9_Aj96QugIjm7y0","status":"SUCCESS","submittedAt":"2021-04-20T08:42:14+0200","submitterLogin":"adam-zamojski58056","startedAt":"2021-04-20T08:42:14+0200","executedAt":"2021-04-20T08:42:21+0200","executionTimeMs":7012,"logs":false,"hasScannerContext":true,"organization":"cdsng","warningCount":1,"warnings":["Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone."]}
##[debug][SQ] Retrieve Analysis id 'AXjuA9_Aj96QugIjm7y0.'
##[debug][SQ] API GET: '/api/qualitygates/project_status' with query "{"analysisId":"AXjuA9_Aj96QugIjm7y0"}"
##[debug]Response: 200 Body: "{"projectStatus":{"status":"OK","conditions":[{"status":"OK","metricKey":"new_reliability_rating","comparator":"GT","periodIndex":1,"errorThreshold":"1","actualValue":"1"},{"status":"OK","metricKey":"new_security_rating","comparator":"GT","periodIndex":1,"errorThreshold":"1","actualValue":"1"},{"status":"OK","metricKey":"new_maintainability_rating","comparator":"GT","periodIndex":1,"errorThreshold":"1","actualValue":"1"},{"status":"OK","metricKey":"new_coverage","comparator":"LT","periodIndex":1,"errorThreshold":"70","actualValue":"85.91549295774648"},{"status":"OK","metricKey":"coverage","comparator":"LT","errorThreshold":"60","actualValue":"83.2"},{"status":"OK","metricKey":"new_duplicated_lines_density","comparator":"GT","periodIndex":1,"errorThreshold":"3","actualValue":"1.3523131672597866"},{"status":"OK","metricKey":"new_blocker_violations","comparator":"GT","periodIndex":1,"errorThreshold":"0","actualValue":"0"},{"status":"OK","metricKey":"new_bugs","comparator":"GT","periodIndex":1,"errorThreshold":"0","actualValue":"0"},{"status":"OK","metricKey":"new_vulnerabilities","comparator":"GT","periodIndex":1,"errorThreshold":"0","actualValue":"0"}],"periods":[{"index":1,"mode":"days","date":"2021-04-07T05:06:37+0200","parameter":"14"}],"ignoredConditions":false}}"
##[debug][SQ] Generate analysis report.'
##[debug]Number of analyses in this build: 1
##[debug]Overall Quality Gate status: ok
##[debug]System.TeamFoundationCollectionUri=https://dev.azure.com/GG/
##[debug]System.TeamProjectId=ggg
##[debug]Build.BuildId=300488
##[debug][{"op":0,"path":"/sonarglobalqualitygate","value":"ok"}]
SYSTEMVSSCONNECTION exists true
##[debug]SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
##[debug]SYSTEMVSSCONNECTION exists true
##[debug]Acquiring a build API object.
##[debug]Creating a new build property with global Quality Gate Status
##[debug]build.artifactStagingDirectory=D:\Agents\S4\_work\25\a
##[debug][SQ] Summary saved at: D:\Agents\S4\_work\25\a\.sqAnalysis\SonarQubeBuildSummary.md
##[debug][SQ] Uploading build summary from D:\Agents\S4\_work\25\a\.sqAnalysis\SonarQubeBuildSummary.md
##[debug]Processed: ##vso[task.addattachment type=Distributedtask.Core.Summary;name=SonarCloud Analysis Report;]D:\Agents\S4\_work\25\a\.sqAnalysis\SonarQubeBuildSummary.md
##[section]Finishing: Publish Quality Gate Result
##[debug]Evaluating: succeeded()
##[debug]Evaluating succeeded:
##[debug]=> True
##[debug]Result: True
##[section]Starting: Publish Quality Gate Result
==============================================================================
Task         : Publish Quality Gate Result
Description  : Publish SonarCloud's Quality Gate result on the Azure Pipelines build result. To be used after the actual analysis.
Version      : 1.10.1
Author       : sonarsource
Help         : Version: 1.10.1. [More Information](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
==============================================================================
##[debug]Using node path: D:\Agents\S4\externals\node\bin\node.exe
##[debug]agent.TempDirectory=D:\Agents\S4\_work\_temp
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_POLLINGTIMEOUTSEC
##[debug]loading SECRET_SONARQUBE_ENDPOINT
##[debug]loaded 5
##[debug]Agent.ProxyUrl=http://proxy:8082
##[debug]Agent.ProxyUsername=undefined
##[debug]Agent.ProxyPassword=undefined
##[debug]Agent.ProxyBypassList=undefined
##[debug]expose agent proxy configuration.
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io/","sonar.login":***,"sonar.organization":"xxx","sonar.projectKey":"xxx","sonar.projectName":"XXX","sonar.projectVersion":"9.1.0.3","sonar.scanner.metadataFilePath":"D:\\Agents\\S4\\_work\\_temp\\sonar\\9.1.0.3\\091ac587-d6a7-a19d-4bca-b16cd985590e\\report-task.txt","sonar.c.file.suffixes":"-","sonar.cpp.file.suffixes":"-","sonar.objc.file.suffixes":"-"}
##[debug]SONARQUBE_ENDPOINT=***
##[debug][SQ] API GET: '/api/metrics/search' with query "{"f":"name","ps":500}"
##[debug][SQ] API GET '/api/metrics/search' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[error][SQ] Could not fetch metrics
##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch metrics
##[error][SQ] API GET '/api/metrics/search' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/metrics/search' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug]pollingTimeoutSec=300
##[debug][SQ] API GET: '/api/server/version' with query "undefined"
##[debug][SQ] API GET '/api/server/version' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug][SQ] Publish task error: [SQ] API GET '/api/server/version' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug]task result: Failed
##[error][SQ] API GET '/api/server/version' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/server/version' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[debug]Processed: ##vso[task.complete result=Failed;][SQ] API GET '/api/server/version' failed, error was: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect","address":"3.125.98.141","port":443}
##[section]Finishing: Publish Quality Gate Result

Please help us to understand and diagnose the issue.

Hello @zamojski, looking at the logs and based on your information i would say that could be a networking issue on your side. As you can see lots of API requests failed due to a ETIMEDOUT which is a timed out connection. It is not related to authentication or something else because simple requests like a GET into https://sonarcloud.io/api/server/version should always work (you can test it anywhere if you want). To me the alternate behavior is not something that must be investigated now: you need to know the reason for the failing requests. You can use the above one for debugging this issue, the following command:

curl -i https://sonarcloud.io/api/server/version

Should return (some values maybe change):

HTTP/1.1 200
Date: Fri, 23 Apr 2021 06:59:41 GMT
Content-Type: text/plain
Content-Length: 11
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-cache, no-store, must-revalidate
Sonar-Version: 8.9.0.43283

8.0.0.19558%

Unfortunately we can’t help much with that, since this issue is on your side. I could find a lot of topics by Google “azure devops ETIMEDOUT”, maybe is a good to start.

I hope that helps.

I was initially assuming the same but both builds were executed on the same agent, the same machine, and one right after another.

Moreover in the same build the ‘Prepare analysis on SonarCloud’ succeeds without any issues so there must be something wrong with ‘Publish Quality Gate Result’ task.

I’m able to connect the the server https://sonarcloud.io/api/server/version in web browser as well as with curl once the proxy is configured.

$ curl -i https://sonarcloud.io/api/server/version
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:01:04 --:--:--     0
curl: (28) Failed to connect to sonarcloud.io port 443: Timed out

XXX@XE-S-XXX MINGW64 ~
$ export https_proxy=http://proxy.com:8082

XXX@XE-S-XXX MINGW64 ~
$ curl -i https://sonarcloud.io/api/server/version
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    11  100    11    0     0      6      0  0:00:01  0:00:01 --:--:--     6HTTP/1.1 200 Connection established

HTTP/1.1 200
Date: Fri, 23 Apr 2021 08:37:12 GMT
Content-Type: text/plain
Content-Length: 11
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-cache, no-store, must-revalidate
Sonar-Version: 8.9.0.43283

8.0.0.19558

And as you can see the proxy is configured on the agent ##[debug]Agent.ProxyUrl=http://proxy:8082.

Could be a proxy issue: some times it fails. The time out happened when you didn’t configure the proxy, so if there is a problem with it you will get a timed out, the same issue you have in the pipeline.

Do you still have this issue? It is consistent (happens always, sometimes, for a specific pipeline)?

No, it’s not true. It always fails for certain build definition while not for the other. The issue is consistent and behaves always the same for certain pipeline.

Is there any way to check why during the same agent job the version check succeeds at the beginning (prepare) and fails at the end (publish quality gate)?

@Alexandre_Holzhey Any ideas how to debug this or where to seek for the differences in behavior?

The build definition for a failing and a good pipeline is exactly the same? Including environment variables values? Including the environment they are executed? If not, what are the differences?

My assumption is: if one pipeline succeeds and other don’t, probably there is something wrong/different between the pipelines. You should start by investigating these differences.

After many tries we have identified the issue. In the only pipeline that worked correctly we were building a Node.js 12 application. On the others we were not. It turned out that if we add Use Node 12 task to the Azure DevOps pipeline the ‘Publish Quality Gate Result’ task succeeds. The default version in Azure DevOps Agent is 6.x and I believe ‘Publish Quality Gate Result’ task uses that one.

The ‘Run Code Analysis’ (one task above in the pipeline) was not failing on on the same call to https://sonarcloud.io/api/server/version . Most likely it internally requires a newer version of Node.js on which the call succeeds.

In my opinion that clearly indicates that the issue is in Sonar Qube Azure DevOps tasks. At least we have a workaround for now but I think it would be better to get it fixed on your side.