3

I have problem with Jenkins – Execute SonarQube Scanner Build Option.

Our Environment details as follows:

 - Jenkins Master Server OS: Ubuntu-12.04 LTS-64 Bit. 
 - Master Server Jenkins Version: 2.46.2 
 - SonarQube Scanner Plugin for Jenkins -Version - 2.6.1 
 - Build Type: Master and Slave Based.  
 - Slave Machine: Ubuntu-14.04-LTS (64-Bit)  
 - SonarQube Server Version - 5.1 (64-Bit)  
 - Sonar-runner version 2.4  
 - Slave Machine Java Version – 1.8

Problem Description:- I have defined the sonar.project.properties information under the “Analysis properties” category in Jenkins Master Server itself,When i tried to execute the same through it fails with below errors.java.lang.UnsupportedClassVersionError:

hudson/plugins/sonar/SonarRunnerInstallation$1 : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
Caused: java.lang.ClassFormatError: Failed to load hudson.plugins.sonar.SonarRunnerInstallation$1

Kindly help me to fix the same.

user4948798
  • 1,924
  • 4
  • 43
  • 89

1 Answers1

5

The issue is because of Java version mismatch. From the Wikipedia Java Class Reference you can fin all the codes: J2SE 8 = 52,J2SE 7 = 51,J2SE 6.0 = 50,J2SE 5.0 = 49

This error is caused becaused you are using a lower JDK at runtime (probably 7) than 8 that is the one used to compile that version of Jenkins

Denis Ismailovski
  • 311
  • 1
  • 7
  • 15
  • Need to be sure the Java version 8 is in your path when you launch Jenkins. The server have both Java 7 and 8 installed. – Denis Ismailovski May 17 '17 at 10:24
  • Hi Denis, My Jenkins slave machine has below variables, JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH Still it fails. – user4948798 May 18 '17 at 03:18
  • If you keep have this issue you can write a JenkinsFile to force set JAVA_HOME 1.7 for the test part and 1.8 for Sonarqube – Denis Ismailovski May 18 '17 at 05:44
  • 1
    Problem solved by adding the JENKINS_JAVA_CMD environment variable and pointing to Java-1.8 path on Node/Slave Machine. – user4948798 Jun 22 '17 at 06:23