How to configure a Jenkins Pipeline for SonarQube scan

喜欢而已 提交于 2019-12-04 08:06:27
user5917011

I needed to add the workspace to my script. Here is the script below:

stage('SonarQube analysis') {
    ws('D:\\my_prj') {
    // requires SonarQube Scanner 2.8+
    def scannerHome = tool 'sonarScanner';
    withSonarQubeEnv('SonarQube 6.2') {
      bat "${scannerHome}/bin/sonar-scanner.bat"
    }
  }
}

I see you were using Sonar-runner 2.4. I think by running 2.8 version you will have better results. This is my JenkinsFile configuration, by using Declarative Pipeline syntax. I was having the same issue, but I solved by renaming my sonar-project.properties file, the previous name was "sonar.properties" and researching(The Sonarqube official docs didn't help me). I hope this may help others.

stage('Sonarqube analysis') {
    steps {
    script {
             scannerHome = tool 'SonarScanner';
        }
     withSonarQubeEnv('SonarQube') {
         bat "${scannerHome}/bin/sonar-scanner.bat" 
    }

    }
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!