Run maven sonar with already compiled java files

Hi Ann,

So when I run that command, it looks like it kicks everything off again to be re-built…

I came across this post that seems to have the same issue (unfortunately the link to the doc the post references, seems to be no longer valid. But I think it was trying to point to here to the “Jenkins” section)

I had to remove the clean and verify part of the command and add in my version. It also looks like you can pass in a -X at the end of maven to turn on debugging.

mvn sonar:sonar -Dsonar.java.source=1.8 -Drevision=1.0.0 -Dsonar.token=myAuthenticationToken -X

This seems to have fixed my particular issue.

Sample scripted jenkins pipeline code (We use pod templates)

...
stage('Build') {
  container('jdk8') {
    sh "mvn compile -Drevision=1.0.0"
    }
}
stage('SonarQube') {
  container('jdk11') {
    withSonarQubeEnv('sonarqube') {
      sh "mvn sonar:sonar -Dsonar.java.source=1.8 -Drevision=1.0.0 -X"
    }
  }
}
...

Thanks for your help!