Failure in Azure DevOps Pipeline with SonarCloudPublish@1 When Fetching Measures from Sonar Cloud

Description:

I am experiencing a specific issue when using the Azure DevOps pipeline in conjunction with the SonarCloudPublish@1 task. The goal is to publish the code analysis results to Sonar Cloud, but the process is interrupted during the step of fetching the measures of my project from Sonar Cloud.

The pipeline runs smoothly until it reaches the SonarCloudPublish@1 task, where the failure occurs. The specific error points to the inability to retrieve the project’s measures from Sonar Cloud. This results in the pipeline breaking, preventing the publication of the analysis results.

  • Azure DevOps

  • CI system used Azure DevOps

Error:


##[debug][SQ] API GET: '/api/measures/component' with full URL "https://sonarcloud.io/api/measures/component?component={{COMPONENT_NAME}}&metricKeys=new_violations%2Cnew_accepted_issues%2Cnew_security_hotspots%2Cnew_coverage%2Cnew_duplicated_lines_density" and query "{"component":"{{COMPONENT_NAME}}","metricKeys":"new_violations,new_accepted_issues,new_security_hotspots,new_coverage,new_duplicated_lines_density"}"

##[debug]Not using a proxy agent

##[debug]Error fetching component measures: Cannot read property 'measures' of undefined

##[debug]Unable to get measures. It is expected if you are not using a user token but instead a global or project analysis token.

##[debug][SQ] Publish task error: Cannot read property 'status' of undefined

##[debug]task result: Failed

##[error]Cannot read property 'status' of undefined

Additional details:

  • The configuration of the task and the Sonar Cloud credentials have been verified and seem to be correct.

  • The code analysis on Sonar Cloud is performed without errors, but the problem arises when trying to publish those results.

  • Used versions: SonarCloudPublish@1 task.

  • This issue began to occur recently, and it was not present in previous pipeline runs.

1 Like

Hi,

Can you share your pipeline?

I think this is not actually about the token but that the step has lost the context of the analysis:

I believe the text about the token is just standard (and normally helpful) boilerplate.

 
Ann

Hi,

I hope this message finds you well.

Pipeline Configuration:
Below is the relevant snippet of our pipeline configuration where the SonarCloud tasks are defined:

          - task: SonarCloudPrepare@1
            displayName: Prepare Sonar Analysis on SonarCloud
            inputs:
              SonarCloud: '######'
              organization: '######'
              scannerMode: CLI
              configMode: manual
              cliProjectKey: '$(REPO_CLI_PROJECT_KEY)'
              cliProjectName: '$(REPO_NAME)'
              cliSources: '.'
              extraProperties: |
                sonar.exclusions=/src/prisma/config/**
                sonar.exclusions=**/*.spec.*

          - task: SonarCloudAnalyze@1
            displayName: Run Sonar Code Analysis

          - task: SonarCloudPublish@1
            displayName: 'Publicando Analise no SonarCloud'
            inputs:
              pollingTimeoutSec: '500'

Pipeline Log Context: Following the pipeline execution, here are some relevant excerpts from the log, with a little bit more context than before:

projectKey=#########
serverUrl=https://sonarcloud.io
serverVersion=8.0.0.53374
dashboardUrl=https://sonarcloud.io/dashboard?id=###########
ceTaskId=#############
ceTaskUrl=https://sonarcloud.io/api/ce/task?id=#############

##[debug][SQ] Waiting for task '#############' to complete.
##[debug][SQ] API GET: '/api/ce/task' with full URL "https://sonarcloud.io/api/ce/task?id=#############&additionalFields=warnings" and query "{"id":"#############","additionalFields":"warnings"}"
##[debug]Not using a proxy agent
##[debug]Agent environment resources - Disk: / Available 17306.00 MB out of 74244.00 MB, Memory: Used 696.00 MB out of 6932.00 MB, CPU: Usage 6.08%
##[debug][SQ] Task status:SUCCESS
##[debug][SQ] Task complete: {"id":"#############","type":"REPORT","componentId":"#############","componentKey":"#############","componentName":"#############","componentQualifier":"TRK","analysisId":"#############","status":"SUCCESS","submittedAt":"2024-03-15T19:21:50+0100","submitterLogin":"serv-azr-devops-sonar12697","startedAt":"2024-03-15T19:21:50+0100","executedAt":"2024-03-15T19:21:53+0100","executionTimeMs":2678,"logs":false,"hasScannerContext":true,"organization":"#############","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]Retrieve Analysis id '#############.'
##[debug][SQ] API GET: '/api/qualitygates/project_status' with full URL "https://sonarcloud.io/api/qualitygates/project_status?analysisId=#############" and query "{"analysisId":"#############"}"
##[debug]Not using a proxy agent
##[debug]SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io","sonar.token":***,"sonar.organization":"#############","sonar.projectKey":"#############","sonar.projectName":"#############","sonar.projectVersion":"1.0","sonar.sources":"/home/vsts/work/1/s","sonar.scanner.metadataFilePath":"/home/vsts/work/_temp/sonar/81795/#############/report-task.txt","sonar.typescript.lcov.reportPaths":"./coverage/lcov.info","sonar.exclusions":"**/*.png,**/*.ico,**/*.svg,**/*.ttf,node_modules/**,node_modules/**/*,**/node_modules/**,**/node_modules/**/*"}
##[debug][SQ] API GET: '/api/measures/component' with full URL "https://sonarcloud.io/api/measures/component?component=#############&metricKeys=new_violations%2Cnew_accepted_issues%2Cnew_security_hotspots%2Cnew_coverage%2Cnew_duplicated_lines_density" and query "{"component":"#############","metricKeys":"new_violations,new_accepted_issues,new_security_hotspots,new_coverage,new_duplicated_lines_density"}"
##[debug]Not using a proxy agent
##[debug]Error fetching component measures: Cannot read property 'measures' of undefined
##[debug]Unable to get measures. It is expected if you are not using a user token but instead a global or project analysis token.
##[debug][SQ] Publish task error: Cannot read property 'status' of undefined
##[debug]task result: Failed
##[error]Cannot read property 'status' of undefined
##[debug]Processed: ##vso[task.issue type=error;]Cannot read property 'status' of undefined
##[debug]Processed: ##vso[task.complete result=Failed;]Cannot read property 'status' of undefined

Thank you for your attention to this matter.

Tiago

Hi,

Thanks for the pipeline and fuller log snippet. The pipeline looks standard. The log snippet blows my earlier theory out of the water, so I’m going to flag this for more expert eyes.

 
Ann

Same problem here!

Anyone has the answer???

Hi @thpf.dev,

Apologies for the very late reply here. Is this still happening for you? If so, could you share with me the full timestamp of when this occurred most recently?

Thanks

Hi Tom,

It is still happening, yes. Last time we got this issue was Friday, 19 April 2024.

Timestamps - miliseconds: 1713533940000

Thanks