I am using sonar 4.5.1 and it is compatible with JDK 1.7 and above .For the projects which are on JDK1.6 in Jenkins , I want to perform sonar analysis using JDK1.7. To achieve this under Jenkins , in maven goals and options , I am using -Dsonar.java.source= jdk1.7.0_76 but during build it seems that jdk1.7.0_76 is not being picked for sonar analysis. Sonar Analysis is still being done with the JDK 1.6 version which is defined in JDK section in Jenkins. This results to the build error : "The plugin findbugs is not supported with Java 1.6.0_26" . I don't want to use the sonar in post build action because it throws some other error so I want to provide the sonar details in maven goals and options only. Why is jdk1.7.0_76 not being picked? What am I missing? Is there any other way of providing the JDK1.7 version?
(Edited)
My requirement : maven analysis should be done using jdk 1.6 and sonar analysis should be done with jdk 1.7 and above (sonar analysis step is provided in maven goals and no Sonar-postbuild action is used)
under Maven goals and options
clean install -Dmaven.test.skip=true -Dsonar.jdbc.url=jdbc:postgresql://sonardb.test.com:5555/sonar -Dsonar.host.url=http://localhost:9000/sonar -Dsonar.java.target=jdk1.8.0_40 -Dsonar.java.source=jdk1.8.0_40 org.codehaus.mojo:sonar-maven-plugin:1.0:sonar -Dsonar.branch=test
Please find below the screenshots
Have a look at your mvn
script:
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
This change is done at the level of your Maven environment. Before launching Maven, you need to set the JAVA_HOME
environment variable to the location of your JDK version 1.7.
I guess that you're using an execute shell
post-build step. If you're using bash
you just need to type JAVA_HOME="path to your JDK 1.7 home"
before the line containing your mvn
command in the command
text area of your Jenkins' job configuration as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With