简体   繁体   中英

401 Unauthorized Sonarqube Analysis with TFS2017

I setup a SonarQube server and included the BuildTask Steps in the TFS2017 Build process. TFS is an on-premise setup.

On "Complete SonarQube analysis" build step i get the following error:

2017-01-30T08:54:30.7388183Z 09:54:30.676  Post-processing succeeded.
2017-01-30T08:54:32.1607278Z ##[error]System.Management.Automation.CmdletInvocationException: {"err_code":401,"err_msg":"Unauthorized"} ---> System.Net.WebException: Der Remoteserver hat einen Fehler zurückgegeben: (401) Nicht autorisiert.
2017-01-30T08:54:32.1607278Z    bei Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
2017-01-30T08:54:32.1607278Z    bei Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
2017-01-30T08:54:32.1607278Z    --- Ende der internen Ausnahmestapelüberwachung ---
2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-01-30T08:54:32.1607278Z    bei System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-01-30T08:54:32.1607278Z    bei Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
2017-01-30T08:54:32.1763500Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.
2017-01-30T08:54:32.1763500Z ##[section]Finishing: Complete the SonarQube analysis

As the analysis finished, I assume this is some kind of logging done by SonarQube afterwards.

Build Agent is installed on server A, SonarQube installed on server B. The "prepare step" Build Task finishes without errors so I assume, the basic SonarQube Setup is ok. I installed SonarQube 5.6.5 LTS and the Sonar User provided in the SonarQube.Analysis.xml is the default admin/admin user.

Any suggestions?

The build tasks do not use the authentication properties in SonarQube.Analysis.xml, you need to specify the authentication token in the SonarQube endpoint in TFS: https://docs.sonarqube.org/display/SCAN/SonarQube+Endpoint

And here is an article about how to obtain the token from SonarQube: https://docs.sonarqube.org/display/SONAR/User+Token

Dont' forget to comment the sonar.login and sonar.password properties again in the SonarQube.Analysis.xml if you uncommented those in the first place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM