How to use sonarqube server from pipeline msbuild scanner in jenkins?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube
  • what are you trying to achieve
    i try to configure a project with msbuild in jenkins.
  • what have you tried so far to achieve this

I add a sonarqube server by Jenkins Configure System
image

install a msbuild scanner from global tool configuration

image

then i use the sanner in pipeline

        scannerHome = tool 'sonarScanner.Msbuild'
        bat "\"${scannerHome}\\SonarScanner.MSBuild.exe\" begin /k:\"project_key\""

I got the error

Failed to request an[d parse 'http://localhost:9000/api/serve](http://localhost:9000/api/server/version)r/version':

I think the error is because it don’t use my sonarqube server I configured before, but i don’t find any document about how to use it in pipeline or set it the default server otherwise localhost:9000.

I find the solution by a withSonarQubeEnv section.
SonarScanner for Jenkins | SonarQube Docs

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.