Authentication failed while integrating Sonarqube community edition latest version with TFS 2022

Starting: Prepare analysis on SonarQube
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarQube analysis configuration
Version      : 5.17.2
Author       : sonarsource
Help         : Version: 5.17.2. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
C:\BuildAgents\***\agent_v2\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.17.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Sonarqube_Core
SonarScanner for MSBuild 5.14
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
08:36:30.204  Updating build integration targets...
##[error]08:36:30.465  Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters.
08:36:30.468  Pre-processing failed. Exit code: 1
08:36:30.465  Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters.
08:36:30.468  Pre-processing failed. Exit code: 1
##[error]The process 'C:\BuildAgents\***\agent_v2\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.17.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Prepare analysis on SonarQube

Hi,

Welcome to the community!

I supose you’re asking for help with that error message?

What does it mean to you?

 
Ann

I’m have this same issue with Azure DevOps Server. If I create a service connection and enter my SonarQube URL and Token I get “##[error]16:36:11.856 Unauthorized: Access is denied due to invalid credentials. Please check the authentication parameters.”

I’ve used ten different Tokens from ‘admin’ to two different administrative users. Combinations of User, Project Analysis and Global Analysis. All fail…

Non-working YAML:

  • task: SonarQubePrepare@5
    displayName: SonarQube Begin
    inputs:
    SonarQube: ‘SonarQubeServer’
    scannerMode: ‘MSBuild’
    projectKey: ‘SMTest’
    projectVersion: ‘1.0’

Working YAML:

  • task: PowerShell@2
    displayName: SonarQube Begin (pwsh)
    inputs:
    targetType: ‘inline’
    script: |
    . “C:\Program Files\dotnet\dotnet.exe” E:\DevOpsTools\sonar-scanner-core\SonarScanner.MSBuild.dll begin -k:“SMTest” -v:“1.0” -d:sonar.token $(SonarQubeToken)

I should also add we are using an enterprise Root CA.

Hi,

I think this is about how you’re passing your token. In the docs the examples all show something like /d:sonar.login="<token>". Note

  • the quotes
  • the equals sign
  • the lack of spaces (probably less important…?)

 
HTH,
Ann

You’re right I left out the quotes, but that was the code that works!

I tried deleting the service connection and creating a new one with the same settings. Then, it started working. So, I think somehow the old service connection became corrupted.

Maybe @Aniruddh_Gujar could try that?

1 Like