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:
https://repox.sonarsource.com/sonarsource-public-builds/org/jenkins-ci/plugins/sonar/2.5-build975/sonar-2.5-build975.hpi

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 {
  git 'https://github.com/foo/bar.git'
  def scannerHome = tool 'SonarQube Scanner 2.8';
  *withSonarQubeEnv* {
    sh "${scannerHome}/bin/sonar-scanner"
  }
}

2) Using Gradle (requires SonarQube Scanner for Gradle 2.1+):

node {
  git 'https://github.com/foo/bar.git'
  *withSonarQubeEnv* {
    sh './gradlew sonarqube' 
  }
}

2) Using Maven (requires SonarQube Scanner for Maven 3.2+):

node {
  git 'https://github.com/foo/bar.git'
  *withSonarQubeEnv* {
    sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar' 
  }
}
If you want to use a specific JDK / Maven version, please read: 
https://jenkins.io/doc/pipeline/examples/#maven-and-jdk-specific-version

3) For MSBuild projects

node {
  git 'https://github.com/foo/bar.git'
  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:
node {
  git 'https://github.com/foo/bar.git'
  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

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4e757ec9-8980-426e-b168-7508bb55d439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to