Unable to parse code using SonarQube scanner for MSBuild -remote error returned 403 forbidden

Hi, we are using sonarqube analyser for MSBuild nuget package = MSBuild.SonarQube.Runner.Tool.

We are running the analysis on bamboo build server (version 6.7.1 build 60705)

In a particular project named gateway, we get an error when running the analysis step before the build:

The remote server returned an error: (403) Forbidden.

Bamboo log as follows


build 14-Feb-2019 10:17:14 Executing .\Src\packages\MSBuild.SonarQube.Runner.Tool.\tools\MSBuild.SonarQube.Runner.exe
build 14-Feb-2019 10:17:14 SonarQube Scanner for MSBuild 4.0.2
build 14-Feb-2019 10:17:14 Default properties file was found at C:\build\STRUSE-SG-JOB1\Src\packages\MSBuild.SonarQube.Runner.Tool.\tools\SonarQube.Analysis.xml
build 14-Feb-2019 10:17:14 Loading analysis properties from C:\build\STRUSE-SG-JOB1\Src\packages\MSBuild.SonarQube.Runner.Tool.\tools\SonarQube.Analysis.xml
build 14-Feb-2019 10:17:14 Pre-processing started.
build 14-Feb-2019 10:17:14 Preparing working directories…
build 14-Feb-2019 10:17:14 10:17:14.991 Updating build integration targets…
build 14-Feb-2019 10:17:14 10:17:14.999 Fetching analysis configuration settings…
build 14-Feb-2019 10:17:17 stderr: 10:17:16.802 Failed to request and parse ‘https://sonarcloud.io/api/settings/values?component=Gateway’: The remote server returned an error: (403) Forbidden.


Do you have information of what could possibly be causing the error?

We analyse many other projects using the same api key.


Given that the scanner fails with an HTTP 403 when trying to get settings for the “Gateway” project, I’d say that the token that you are using does not have enough credentials to access this project.

Hi @Fabrice_Bellingard

I am facing the same issue, when I am trying to analyse the dotnet project with MsBuild Plugin. I am doing this analysis via Jenkins, so I am using a token from admin user, technically has access to do everything in sonarqube.

However, I was able to do the analysis with sonarscanner CLI, but I am seeing issues only when I am trying this with Sonar Scanner MsBuild Plugin.

Jenkins Pipeline Output:

  • dotnet sonarscanner begin /k:Sample-dotnet-MsBuild
    SonarScanner for MSBuild 4.10
    Using the .NET Core version of the Scanner for MSBuild
    Pre-processing started.
    Preparing working directories…
    11:27:43.566 Updating build integration targets…
    11:27:43.653 Fetching analysis configuration settings…
    11:27:44.176 Failed to request and parse ‘http://soanrqube.xyz.com/api/server/version’: The remote server returned an error: (403) Forbidden.
    Unhandled exception. System.Net.WebException: The remote server returned an error: (403) Forbidden.
    at System.Net.HttpWebRequest.GetResponse() in //src/System.Net.Requests/src/System/Net/HttpWebRequest.cs:line 1004
    at System.Net.WebClient.GetWebResponse(WebRequest request) in /
    /src/System.Net.WebClient/src/System/Net/WebClient.cs:line 249
    at System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream) in //src/System.Net.WebClient/src/System/Net/WebClient.cs:line 818
    at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) in /
    /src/System.Net.WebClient/src/System/Net/WebClient.cs:line 297
    at System.Net.WebClient.DownloadString(Uri address) in //src/System.Net.WebClient/src/System/Net/WebClient.cs:line 684
    at System.Net.WebClient.DownloadString(String address) in /
    /src/System.Net.WebClient/src/System/Net/WebClient.cs:line 674
    at SonarScanner.MSBuild.PreProcessor.WebClientDownloader.Download(String url)
    at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass15_0.b__0()
    at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func1 op, String url, Action1 onError)
    at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion()
    at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion()
    at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetProperties(String projectKey, String projectBranch)
    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, IDictionary2& serverSettings, List1& analyzersSettings)
    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute(String args)
    at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
    at SonarScanner.MSBuild.BootstrapperClass.Execute()
    at SonarScanner.MSBuild.Program.Execute(String args, ILogger logger)
    at SonarScanner.MSBuild.Program.Execute(String args, Boolean showDeprecatedWarning)
    at SonarScanner.MSBuild.Program.Main(String args)
    [Pipeline] }
    WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeeded?