Sherlocker
Sherlocker

Reputation: 355

Pipeline is not working with sonarQube with Jenkins and windows

Good afternoon, friends from Stack !

I am running a SonarQube in my pipeline in a jenkins instance. I have an issue and I'm following the documentation and I am kid of new to this.

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins

But I have a Windows slaves. And everytime I configure it according to the documentation I get an error...

[Sonar-Pipeline] Running batch script

C:\Program Files (x86)\Jenkins\workspace\Sonar-Pipeline>C: \Program Files (x86)\Jenkins\tools    \hudson.plugins.sonar.SonarRunnerInstallation\SONAR_RUNNER\bin\sonar-scanner 
'C:\Program' not‚ recongnized as an internal or external command.

After which I beleive that there is a space here and Jenkins is trying to execute only 'C:Program ' as the above shows. Does any body now this?

This is my pipeline...

node {

  stage('SonarQube analysis') {
  // requires SonarQube Scanner 2.8+
  def scannerHome = tool 'SONAR_RUNNER';
  withSonarQubeEnv('SonarQube') {
  bat "${scannerHome}/bin/sonar-scanner"
 }
}

}

So this is what I am trying to execute according to the documentation. The only thing that is asked, because I am using only windows is to switch to bat instead of sh on scannerHome execution. Because it is a pipeline also and not a normal option. And I do have all the files too.

Upvotes: 0

Views: 936

Answers (1)

ganesh
ganesh

Reputation: 11

Please use below code to run the sonar-scanner on windows

node {    
       stage('SonarQube analysis') {
       // requires SonarQube Scanner 2.8+
       def scannerHome = tool 'SONAR_RUNNER';
       withSonarQubeEnv('SonarQube') {
            bat "\"${scannerHome}\\bin\\sonar-scanner.bat\""
       }
}

Upvotes: 1

Related Questions