Hi,
Based on feedback we get during first release candidate, we decided to simplify our DSL compared to the first release candidate and now heavily rely on sh/bat steps instead of providing one specific step for each SonarQube scanner. As a result, here is a new releease candidate you can test:
Only remains the withSonarQubeEnv closure that will inject your SonarQube server connection details into some environment variables that latest versions of SonarQube scanners (CLI, Maven, Ant, Gradle, MSBuild, ...) are automatically picking.
And here are the updated DSL snippets (you should of course replace 'sh' by 'bat' on Windows):
1) Using SonarQube Scanner (requires SonarQube Scanner 2.8+):
node {
def scannerHome = tool 'SonarQube Scanner 2.8';
withSonarQubeEnv {
sh "${scannerHome}/bin/sonar-scanner"
}
}
2) Using Gradle (requires SonarQube Scanner for Gradle 2.1+):
node {
withSonarQubeEnv {
sh './gradlew sonarqube'
}
}
2) Using Maven (requires SonarQube Scanner for Maven 3.2+):
node {
withSonarQubeEnv {
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar'
}
} def sqScannerMsBuildHome = tool 'Scanner for MSBuild 2.1'
withSonarQubeEnv {
bat "${sqScannerMsBuildHome}\\MSBuild.SonarQube.Runner.exe begin /k:myKey /n:myName /v:1.0 /d:sonar.host.url=%SONAR_HOST_URL% /d:sonar.login=%SONAR_AUTH_TOKEN%"
bat 'MSBuild.exe /t:Rebuild'
bat "${sqScannerMsBuildHome}\\MSBuild.SonarQube.Runner.exe end /d:sonar.login=%SONAR_AUTH_TOKEN%"
}
}
Once Scanner for MSBuild 2.2 will be released, you'll be able to use:
def sqScannerMsBuildHome = tool 'Scanner for MSBuild 2.2'
withSonarQubeEnv {
bat "${sqScannerMsBuildHome}\\MSBuild.SonarQube.Runner.exe begin /k:myKey /n:myName /v:1.0"
bat 'MSBuild.exe /t:Rebuild'
bat "${sqScannerMsBuildHome}\\MSBuild.SonarQube.Runner.exe end"
}
}
Any feedback is welcome. The final release is expected to be done next week.
++
Julien