Template for a good bug report, formatted with Markdown:
- versions used:
** Sonarqube 7.9.1 (from Docker Hub), SonarQube Azure DevOps extension 4.8.0, Running Azure pipelines on Microsoft Hosted build agents. - Error is: 401 Unauthorized when running ‘Prepare analysis’ task.
- Extension has been configured with Token, there is no user/password config option for this extension. However, in full output mode, the following shows in the logs:
2019-09-23T14:52:16.4210820Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f=https://<redacted>/
2019-09-23T14:52:16.4213017Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param apitoken = null
2019-09-23T14:52:16.4215750Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param username = ***
2019-09-23T14:52:16.4216973Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param password = ***
This implies that the token is being ignored, and some unchangeable username/password combination is being used. I’ve removed the extension and re-installed, and also recreated the service connection multiple times, but it continues to fail.
More complete log output:
2019-09-23T14:52:16.4210820Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f=https://<Removed>/
2019-09-23T14:52:16.4213017Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param apitoken = null
2019-09-23T14:52:16.4215750Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param username = ***
2019-09-23T14:52:16.4216973Z ##[debug]fdc5fbce-98c2-4698-a491-6966e8c4216f auth param password = ***
...
2019-09-23T14:52:16.8368357Z ##[debug][SQ] Branch and PR parameters: {"sonar.scanner.metadataFilePath":"d:\\a\\_temp\\sonar\\20190923.23\\cfbb44b9-8498-0941-9a89-6307e0039821\\report-task.txt"}
2019-09-23T14:52:16.8372423Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner,
2019-09-23T14:52:16.8377096Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2019-09-23T14:52:16.8395024Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;issecret=false;]MSBuild
2019-09-23T14:52:16.8395586Z ##[debug]set SONARQUBE_ENDPOINT=********
2019-09-23T14:52:16.8396741Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;issecret=true;]***
2019-09-23T14:52:16.8397170Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://<Removed>/","sonar.login":***,"sonar.password":***,"sonar.projectKey":"Core-API","sonar.projectName":"Core-API","sonar.projectVersion":"1.0","sonar.scanner.metadataFilePath":"d:\\a\\_temp\\sonar\\20190923.23\\cfbb44b9-8498-0941-9a89-6307e0039821\\report-task.txt"}
2019-09-23T14:52:16.8397734Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;issecret=false;]{"sonar.host.url":"https://<Removed>/","sonar.login":***,"sonar.password":***,"sonar.projectKey":"<Removed>","sonar.projectName":"<Removed>","sonar.projectVersion":"1.0","sonar.scanner.metadataFilePath":"d:\\a\\_temp\\sonar\\20190923.23\\cfbb44b9-8498-0941-9a89-6307e0039821\\report-task.txt"}
2019-09-23T14:52:16.8407723Z ##[debug]Absolute path for pathSegments: d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0,classic-sonar-scanner-msbuild,SonarScanner.MSBuild.exe = d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2019-09-23T14:52:16.8408199Z ##[debug]Using classic scanner at d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2019-09-23T14:52:16.8408473Z ##[debug]set SONARQUBE_SCANNER_MSBUILD_EXE=d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2019-09-23T14:52:16.8408852Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MSBUILD_EXE;issecret=false;]d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2019-09-23T14:52:16.8412528Z ##[debug]which 'd:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2019-09-23T14:52:16.8419422Z ##[debug]found: 'd:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2019-09-23T14:52:16.8419814Z ##[debug]which 'd:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2019-09-23T14:52:16.8420121Z ##[debug]found: 'd:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2019-09-23T14:52:16.8424541Z ##[debug]d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: begin
2019-09-23T14:52:16.8425367Z ##[debug]d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /k:Core-API
2019-09-23T14:52:16.8426574Z ##[debug]system.debug=true
2019-09-23T14:52:16.8426898Z ##[debug]d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /d:sonar.verbose=true
2019-09-23T14:52:16.8432157Z ##[debug]exec tool: d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2019-09-23T14:52:16.8432649Z ##[debug]arguments:
2019-09-23T14:52:16.8432910Z ##[debug] begin
2019-09-23T14:52:16.8433197Z ##[debug] /k:Core-API
2019-09-23T14:52:16.8433459Z ##[debug] /d:sonar.verbose=true
2019-09-23T14:52:16.8441598Z [command]d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Core-API /d:sonar.verbose=true
2019-09-23T14:52:16.8933638Z SonarScanner for MSBuild 4.7.1
2019-09-23T14:52:16.8934147Z Using the .NET Framework version of the Scanner for MSBuild
2019-09-23T14:52:16.9541891Z Default properties file was found at d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2019-09-23T14:52:16.9542358Z Loading analysis properties from d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2019-09-23T14:52:16.9542637Z sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2019-09-23T14:52:16.9545596Z Pre-processing started.
2019-09-23T14:52:16.9559668Z Preparing working directories...
2019-09-23T14:52:16.9577639Z Using environment variables to determine the download directory...
2019-09-23T14:52:16.9583436Z Using environment variable 'AGENT_BUILDDIRECTORY', value 'd:\a\1'
2019-09-23T14:52:17.0231937Z 14:52:17.016 14:52:17 Loading analysis properties from d:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2019-09-23T14:52:17.0232435Z 14:52:17.016 14:52:17.016 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2019-09-23T14:52:17.0354449Z 14:52:17.032 Updating build integration targets...
2019-09-23T14:52:17.0418834Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0430149Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0440328Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0450450Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0462213Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0472351Z 14:52:17.032 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0515485Z 14:52:17.047 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
2019-09-23T14:52:17.0561180Z 14:52:17.047 Installed SonarQube.Integration.targets to d:\a\1\.sonarqube\bin\targets
2019-09-23T14:52:17.0574186Z 14:52:17.047 Creating config and output folders...
2019-09-23T14:52:17.0586754Z 14:52:17.047 Creating directory: d:\a\1\.sonarqube\conf
2019-09-23T14:52:17.0588348Z 14:52:17.047 Creating directory: d:\a\1\.sonarqube\out
2019-09-23T14:52:17.0763452Z 14:52:17.063 Fetching analysis configuration settings...
2019-09-23T14:52:17.0796151Z 14:52:17.079 Downloading from https://<Removed>/api/server/version...
2019-09-23T14:52:17.1424307Z 14:52:17.141 Fetching properties for project '<Removed>' from https://<Removed>/api/settings/values?component=<Removed>...
2019-09-23T14:52:17.1428416Z 14:52:17.141 Downloading from https://<Removed>/api/settings/values?component=<Removed>...
2019-09-23T14:52:17.1844890Z ##[error]14:52:17.172 Failed to request and parse 'https://<Removed>/api/settings/values?component=<Removed>': The remote server returned an error: (401) Unauthorized.
2019-09-23T14:52:17.1853683Z ##[debug]Processed: ##vso[task.logissue type=error;]14:52:17.172 Failed to request and parse 'https://<Removed>/api/settings/values?component=<Removed>': The remote server returned an error: (401) Unauthorized.
2019-09-23T14:52:17.1853973Z 14:52:17.172 Failed to request and parse 'https://<Removed>/api/settings/values?component=<Removed>': The remote server returned an error: (401) Unauthorized.
2019-09-23T14:52:17.1854545Z ##[error]14:52:17.172 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
2019-09-23T14:52:17.1854764Z ##[debug]Processed: ##vso[task.logissue type=error;]14:52:17.172 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
2019-09-23T14:52:17.1854879Z 14:52:17.172 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
2019-09-23T14:52:17.1855048Z ##[error]14:52:17.172 Pre-processing failed. Exit code: 1
Any help would be greatly appreciated!