SonarQubePrepare task failing authentication

I’ve tried most of the suggestions on the forum (like checking the CA cert is in place for Java on SonarQube). I’ve got an azuredevops service connection defined with a token generated by SonarQube. However, the SonarQubePrepare task reports the following:

##[debug]loaded 15

##[debug]Agent.ProxyUrl=undefined

##[debug]Agent.CAInfo=undefined

##[debug]Agent.ClientCert=undefined

##[debug]Agent.SkipCertValidation=undefined

##[debug]SonarQube=0c397863-4cc7-48c4-9f3c-6368187a94ab

##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab=http://iads-sonarqube:9000/

##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param apitoken = undefined

##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param username = ***

##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param password = undefined

##[debug]organization=undefined

##[debug]scannerMode=CLI

##[debug]configMode=file

##[debug]configFile=/home/azuredevops/myagent/_work/1/s/sonar-project.properties

##[debug][SQ] API GET: '/api/server/version' with query "undefined"

##[debug]Response: 200 Body: "10.0.0.68432"

##[debug]System.TeamFoundationCollectionUri=https://ult-ldw-devops.ueccs.co.uk/SDE/

##[debug]System.PullRequest.PullRequestId=undefined

##[debug]Build.Repository.Provider=TfsGit

##[debug]Build.SourceBranch=refs/heads/sonarqube-test

##[debug]SYSTEMVSSCONNECTION exists true

##[warning]Unable to get default branch, defaulting to 'master': Error: unable to verify the first certificate

##[debug]Processed: ##vso[task.issue type=warning;]Unable to get default branch, defaulting to 'master': Error: unable to verify the first certificate

##[debug]Build.SourceBranch=refs/heads/sonarqube-test

##[debug]SonarCloud or SonarQube version >= 7.2.0 detected, setting report-task.txt file to its newest location.

##[debug]Agent.TempDirectory=/home/azuredevops/myagent/_work/_temp

##[debug]Build.BuildNumber=20230609.44

##[debug][SQ] Branch and PR parameters: {"sonar.branch.name":"sonarqube-test","sonar.scanner.metadataFilePath":"/home/azuredevops/myagent/_work/_temp/sonar/20230609.44/0be24fb9-77ff-a6f4-2228-6ce283d72a93/report-task.txt"}

##[debug]extraProperties=sonar.cfamily.build-wrapper-output=gc/c++/build/Release/build_wrapper_output_directory

I don’t know how to get the token passed in. I’ve run the scanner from the command line on the build server so I know it works once invoked (albeit I have to deined the token in the scanner’s sonar.properties file)

Hey there.

I see this warning:

But I don’t see the actual error that’s causing the analysis to fail. Are there some missing logs?

Hi Colin,

Please find below

2023-06-12T08:40:43.5354489Z ##[debug]Evaluating condition for step: 'SonarQubePrepare'
2023-06-12T08:40:43.5356076Z ##[debug]Evaluating: SucceededNode()
2023-06-12T08:40:43.5356585Z ##[debug]Evaluating SucceededNode:
2023-06-12T08:40:43.5357811Z ##[debug]=> True
2023-06-12T08:40:43.5358479Z ##[debug]Result: True
2023-06-12T08:40:43.5359021Z ##[section]Starting: SonarQubePrepare
2023-06-12T08:40:43.5365681Z ==============================================================================
2023-06-12T08:40:43.5365992Z Task         : Prepare Analysis Configuration
2023-06-12T08:40:43.5366245Z Description  : Prepare SonarQube analysis configuration
2023-06-12T08:40:43.5366465Z Version      : 5.13.0
2023-06-12T08:40:43.5366648Z Author       : sonarsource
2023-06-12T08:40:43.5366986Z Help         : Version: 5.13.0. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2023-06-12T08:40:43.5367390Z ==============================================================================
2023-06-12T08:40:43.5544735Z ##[debug]Using node path: /home/azuredevops/myagent/externals/node10/bin/node
2023-06-12T08:40:43.6636246Z ##[debug]agent.TempDirectory=/home/azuredevops/myagent/_work/_temp
2023-06-12T08:40:43.6650399Z ##[debug]loading inputs and endpoints
2023-06-12T08:40:43.6656110Z ##[debug]loading INPUT_SONARQUBE
2023-06-12T08:40:43.6668109Z ##[debug]loading INPUT_SCANNERMODE
2023-06-12T08:40:43.6669536Z ##[debug]loading INPUT_CONFIGMODE
2023-06-12T08:40:43.6670869Z ##[debug]loading INPUT_CONFIGFILE
2023-06-12T08:40:43.6672196Z ##[debug]loading INPUT_CLIPROJECTVERSION
2023-06-12T08:40:43.6673598Z ##[debug]loading INPUT_PROJECTVERSION
2023-06-12T08:40:43.6674922Z ##[debug]loading INPUT_CLISOURCES
2023-06-12T08:40:43.6676254Z ##[debug]loading INPUT_EXTRAPROPERTIES
2023-06-12T08:40:43.6678746Z ##[debug]loading ENDPOINT_AUTH_0c397863-4cc7-48c4-9f3c-6368187a94ab
2023-06-12T08:40:43.6681476Z ##[debug]loading ENDPOINT_AUTH_SCHEME_0c397863-4cc7-48c4-9f3c-6368187a94ab
2023-06-12T08:40:43.6683474Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_0c397863-4cc7-48c4-9f3c-6368187a94ab_USERNAME
2023-06-12T08:40:43.6685142Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-06-12T08:40:43.6686642Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-06-12T08:40:43.6688527Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-06-12T08:40:43.6690217Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-06-12T08:40:43.6691601Z ##[debug]loaded 15
2023-06-12T08:40:43.6692852Z ##[debug]Agent.ProxyUrl=undefined
2023-06-12T08:40:43.6694129Z ##[debug]Agent.CAInfo=undefined
2023-06-12T08:40:43.6695435Z ##[debug]Agent.ClientCert=undefined
2023-06-12T08:40:43.6696812Z ##[debug]Agent.SkipCertValidation=undefined
2023-06-12T08:40:43.9014196Z ##[debug]SonarQube=0c397863-4cc7-48c4-9f3c-6368187a94ab
2023-06-12T08:40:43.9018735Z ##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab=http://iads-sonarqube:9000/
2023-06-12T08:40:43.9022514Z ##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param apitoken = undefined
2023-06-12T08:40:43.9027264Z ##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param username = ***
2023-06-12T08:40:43.9030799Z ##[debug]0c397863-4cc7-48c4-9f3c-6368187a94ab auth param password = undefined
2023-06-12T08:40:43.9033618Z ##[debug]organization=undefined
2023-06-12T08:40:43.9036462Z ##[debug]scannerMode=CLI
2023-06-12T08:40:43.9039407Z ##[debug]configMode=file
2023-06-12T08:40:43.9042231Z ##[debug]configFile=/home/azuredevops/myagent/_work/1/s/sonar-project.properties
2023-06-12T08:40:43.9045127Z ##[debug][SQ] API GET: '/api/server/version' with query "undefined"
2023-06-12T08:40:43.9246327Z ##[debug]Response: 200 Body: "10.0.0.68432"
2023-06-12T08:40:43.9269027Z ##[debug]System.TeamFoundationCollectionUri=https://ult-ldw-devops.ueccs.co.uk/SDE/
2023-06-12T08:40:43.9269897Z ##[debug]System.PullRequest.PullRequestId=undefined
2023-06-12T08:40:43.9270851Z ##[debug]Build.Repository.Provider=TfsGit
2023-06-12T08:40:43.9271692Z ##[debug]Build.SourceBranch=refs/heads/sonarqube-test
2023-06-12T08:40:43.9272997Z ##[debug]SYSTEMVSSCONNECTION exists true
2023-06-12T08:40:43.9655965Z ##[warning]Unable to get default branch, defaulting to 'master': Error: unable to verify the first certificate
2023-06-12T08:40:43.9668761Z ##[debug]Processed: ##vso[task.issue type=warning;]Unable to get default branch, defaulting to 'master': Error: unable to verify the first certificate
2023-06-12T08:40:43.9671424Z ##[debug]Build.SourceBranch=refs/heads/sonarqube-test
2023-06-12T08:40:43.9672417Z ##[debug]SonarCloud or SonarQube version >= 7.2.0 detected, setting report-task.txt file to its newest location.
2023-06-12T08:40:43.9673235Z ##[debug]Agent.TempDirectory=/home/azuredevops/myagent/_work/_temp
2023-06-12T08:40:43.9673895Z ##[debug]Build.BuildNumber=20230612.1
2023-06-12T08:40:43.9675055Z ##[debug][SQ] Branch and PR parameters: {"sonar.branch.name":"sonarqube-test","sonar.scanner.metadataFilePath":"/home/azuredevops/myagent/_work/_temp/sonar/20230612.1/ea2fe886-67fa-8327-051a-33ecfc74b914/report-task.txt"}
2023-06-12T08:40:43.9676766Z ##[debug]extraProperties=sonar.cfamily.build-wrapper-output=gc/c++/build/Release/build_wrapper_output_directory
-X
sonar.login=sqa_09dfcc8c8332aaac53c336d2382061df87fd4fc7
2023-06-12T08:40:43.9677788Z ##[debug]set SONARQUBE_SCANNER_MODE=CLI
2023-06-12T08:40:43.9683286Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;isOutput=false;issecret=false;]CLI
2023-06-12T08:40:43.9684171Z ##[debug]set SONARQUBE_ENDPOINT=********
2023-06-12T08:40:43.9688637Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;isOutput=false;issecret=true;]***
2023-06-12T08:40:43.9691208Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"http://iads-sonarqube:9000/","sonar.login":"sqa_09dfcc8c8332aaac53c336d2382061df87fd4fc7","project.settings":"/home/azuredevops/myagent/_work/1/s/sonar-project.properties","sonar.branch.name":"sonarqube-test","sonar.scanner.metadataFilePath":"/home/azuredevops/myagent/_work/_temp/sonar/20230612.1/ea2fe886-67fa-8327-051a-33ecfc74b914/report-task.txt","sonar.cfamily.build-wrapper-output":"gc/c++/build/Release/build_wrapper_output_directory"}
2023-06-12T08:40:43.9697174Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;isOutput=false;issecret=false;]{"sonar.host.url":"http://iads-sonarqube:9000/","sonar.login":"sqa_09dfcc8c8332aaac53c336d2382061df87fd4fc7","project.settings":"/home/azuredevops/myagent/_work/1/s/sonar-project.properties","sonar.branch.name":"sonarqube-test","sonar.scanner.metadataFilePath":"/home/azuredevops/myagent/_work/_temp/sonar/20230612.1/ea2fe886-67fa-8327-051a-33ecfc74b914/report-task.txt","sonar.cfamily.build-wrapper-output":"gc/c++/build/Release/build_wrapper_output_directory"}
2023-06-12T08:40:43.9746272Z ##[section]Finishing: SonarQubePrepare

It still looks like the Prepare task finished successfully. What is the actual error you’re receiving that fails the pipeline?

It looks like the above errors are red herrings. The issue turned out to be the extraProperties property. The value has to be in quotes and arguments have to be separated by using ‘\n’ and it has to be on the same line as the property name. The documentation isn’t clear enough as it indicates arguments should be on separate lines. The continuation character ‘|’ doesn’t seem to be supported either.