Sonarcloud Publish Task failed in Azure DevOps with Operation cancelled

I have already provided all logs in private message as well here .

HI @prakashmenon19

Have you sent the latest logs to @Aura in a private message? As I have explained in another private message, she is currently unavailable and I am taking over on this thread.

@Aura requested the logs from the file 1_job.txt. Here I can see multiple logs you uploaded, but not that one. Can you please provide that file by responding to the private message I have sent?

Hi @prakashmenon19
Thank you for the last log file.

After investigation, I see 2 different issues.
The initial issue for the scan on Sep 20 has timed out due to slow processing on our side. I was not able to find the root cause of the slow processing at that date.

We asked for a fresh log to see if the same issue is happening again, and it is not the case. Your last issue is due to the same problem you raised in this discussion: Sonar Analysis Branch is not populating in sonar Cloud - #35 by prakashmenon19

My colleague reminded me that we are processing only one scan report at a time for a given project. That explains the issue you saw on Sep 20. When you submitted the scan report, you already had 20 other scans in the pipe for the same project. As the other scan reports already in the pipe have to be processed first, the one you were waiting on has timed out on AzDO because we were busy processing the previous ones

Hi Dejan, We are not able to run a single scan in project . We are seeing this issue in all runs. Pipelines are getting cancelled due to this error. Can we have solution please ASAP.

Hi @prakashmenon19

Sorry to hear that you are blocked. The issue is really what you have raised in the other discussion Sonar Analysis Branch is not populating in sonar Cloud - #35 by prakashmenon19

I see in the other discussion that @AlxO has created a change ticket for the issue you are facing.

Both are different issues. The issue which is raised in Sonar Analysis Branch is not populating in sonar Cloud is different. That is with respet to UI project where we have angular code and sonar analysis is being done on docker file. It was working fine and suddenly stopped working and now its not working. This issue is different Sonarcloud Publish Task failed in Azure DevOps with Operation cancelled which is respect to API where the sonar task runs for 1 our and then pipeline fails . Both the issue still persists. This is going round and round with no solution .

Hi @prakashmenon19

The publish action is failing because it is not able to get the result of the scan. The result of the scan cannot be completed due to the same issue described in the other discussion. I can only encourage you to follow the advice from AlexO in the other discussion

Hi Dejan,

Both the issues are independent. The issue raised in another discussion is w.r.t Docker sonar scan and in that scan analysis is happening but we are not able to see branch in sonar cloud. In this case the issue is different , It’s w.r.t API sonar scan which used to work previously with no issues.

Hi @prakashmenon19

I still think both issues are the same. I have checked the logs of the last analysis you sent here, and the logs in the other ticket and they both fail due to the same issue. There is a timeout in the middle of the process. From what I see in the other ticket, the timeout is due to the number of branches present in your SonarCloud project.

What is happening here: You are scanning the code with the scanner and the result of the scan is sent to SonarCloud. SonarCloud has then to analyze/process the scanning report. During that processing, there is a timeout (the same timeout as in the other discussion) and the process cannot finish. Then in AzDO, when you launch the Publish step, it will wait for the analysis on SonarCloud to be finished, but this is not happening due to the timeout on SonarCloud. After the specified timeout, the Publish action will also timeout.

To me, it is the same issue that translates differently depending on how you are getting the analysis results.

I’m happy to check again one recent analysis (please send me the 1_job.txt) to see if it is failing at the same step during the analysis on SonarCloud.

Hi Dejan,

Now it’s working and pipeline is getting success now . Sonar publish task is working and can see all the short lived branches are removed. Seems it’s removed from backend. But one issue is we are not able to see the “develop” branch in short lived branches. Please check it. We have run the analysis from develop branch.

I have tested with creating new feature barcnh and running sonar analysis and its working fine

HI @prakashmenon19

Happy to see it is now working.

From the screenshot, I was able to get the analysis ID. Next time, please provide the analysis ID as text, it will be easier to check

From what I can see in that analysis, the branch name has not been specified.

What is your default branch in AzDO ? If develop is specified as the default branch, then the branch name is not passed to the sonar scanner, and we will store it in the default branch defined on SonarCloud, which is master in your case.

If that’s not enough, please send again the 1_job.txt of your develop analysis for further investigations

Hi @dejan.milisavljevic , We don’t explicitly provide branch name in our sonar cloud prepare task and this used to work previously. Below is the sonar cloud prepare task which we use.

  • task: SonarCloudPrepare@1
    SonarCloud: ‘${{ parameters.displayname1 }}’
    organization: ‘gemini-sustain-plus’
    scannerMode: ‘Other’
    extraProperties: |
    # Additional properties that will be passed to the scanner,
    # Put one key=value per line, example:
    Note : Key and Name we provide from main yaml file from variables.

I have investigated from my side and what Can I see is when we explicitly specify the branch name as its working and develop branch is getting populated and updated in sonar cloud but this is not the expectation we have . When the sonar analysis is run on any new feature branch without even specifying branch name it gives branch in sonar cloud but for develop branch ONLY this issue we see.

Logs atttached.

If you see when we specify branch name in pipeline logs we see as below:

When we don’t specify branch name then the pipeline logs as below:

Logs as below for both runs 1_jobs:

No Branch name.txt (5.7 MB)
Branch name = develop.txt (4.8 MB)

HI @prakashmenon19

What is your default branch in AzDO and what is the SCM provider ?

SCM is Azure Repo. Default branch is “develop”

Hi @prakashmenon19

Thanks. So, as your default branch is develop, the branch name is not set in the prepare task. It will end up in the default branch on SonarCloud, which is “master” in your case. To have it working as you expect, you need to have the same default branch in both.

ok can you please let me know how to set develop as default branch in sonar cloud.

Hi @prakashmenon19

What you need to do is

  • Delete the develop branch in SonarCloud. I think this should not be a big issue as you just started scanning it apparently
  • Rename, in SonarCloud, the “master” branch to “develop”

Thanks I have done the same but it does not shows the quality gate

It should show Failed / passed like below

Please check what is displayed under the question mark