Run Code Analysis fails for PR builds in Azure pipeline

  • ALM used: Azure DevOps

  • CI system used: Azure DevOps

  • Languages of the repository: .NET

  • Error observed:
    INFO: Load branch configuration
    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION FAILURE
    INFO: ------------------------------------------------------------------------
    INFO: Total time: 47.168s
    INFO: Final Memory: 7M/27M
    INFO: ------------------------------------------------------------------------
    ##[error]ERROR: Error during SonarScanner execution
    ERROR: Not authorized. Please check the properties sonar.login and sonar.password.

  • Steps to reproduce
    Every time PR build is scheduled

  • Potential workaround

We are using “Prepare Code Analysis for SonarCloud” and “Run Code Analysis” steps in build pipeline,
sometime last week Run code analysis started to fail for PR builds with error above.
When build is manually triggered for a branch everything work fine.

Hi @Kiryl and welcome to the community !

Can you check in your Organization general settings, under Azure DevOps Connectivity management, that your Personal Access token is still valid ?

Thanks.

Mickaël

Hello Mickaël and thank you.
Yes, token is still valid, that was one of first things I checked when we started getting this error.

I expect that with expired\bad token manually triggered build would fail as well, so it has to do something with PR specific builds.

That’s not the one i wanted you to check :slight_smile:

It’s the one on SonarCloud, under your organization General Settings, you’ll find this kind of page :

Thanks for clarifying,
I don’t think I ever configured that, so it’s expected that it shows invalid for me.

The way I configured projects:

  • Added them in Sonar Cloud UI and generated project key and token
  • Created service connection in Azure Dev Ops using token from #1 (and my screenshot above)
  • Used that project specific connection in the build pipeline for “Run Code Analysis” step

Everything worked fine until 4/8 - 4/9, my initial thought was that new version of SonarCloud was deployed and they changed the way you need to authenticate.
But obviously that is just a guess.

If you were decorating pull request ever since, you need somehow a personal access token. If you haven’t linked your Azure DevOps organization with the SonarCloud, then this PAT is most likely setup in the setting of the project itself (On your project overview, go to Administration, General Settings, then click on Pull Request)

There are no validation of the token at this stage, but maybe try to update it.

Mickaël

Let me try to configure it with personal token to see if that helps, while I still want to figure out why current configuration broke that seems like a reasonable workaround.

I generated personal token, saved it on SonarCloud and configured pull requests to use it:

That helped and “Run Code Analysis” step works as expected now.

I’ll keep looking and if I find exact reason why original setup broke I’ll let you know.

Thanks again for your time and help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.