2

This is the log I get:

[09/25/15 11:02:03] [SSH] Opening SSH connection to XXXXXXX:22.
[09/25/15 11:02:04] [SSH] Authentication successful.
[09/25/15 11:02:04] [SSH] The remote users environment is:
ERRNO=22
FCEDIT=/bin/ed
HOME=/export/home/xxxx
IFS='   
'
LC_COLLATE=en_US
LC_CTYPE=en_US
LC_MESSAGES=C
LC_MONETARY=en_US
LC_NUMERIC=en_US
LC_TIME=en_US
LINENO=1
LOGNAME=xxxx
MAIL=/var/mail/xxxx
MAILCHECK=600
OPTIND=1
PATH=/usr/bin:/bin
PPID=27709
PS2='> '
PS3='#? '
PS4='+ '
PWD=/export/home/xxxx
RANDOM=23490
SECONDS=0
SHELL=/bin/ksh
SSH_CLIENT='xxx.xxx.xxx.xxx 63489 22'
SSH_CONNECTION=xxx.xxx.xxx.xxx 63489 xxx.xxx.xxx.xxx22'
TMOUT=0
TZ=Europe/Brussels
USER=scv2
_
[09/25/15 11:02:04] [SSH] Checking java version of java
[09/25/15 11:02:04] [SSH] java -version returned 1.5.0_38.
[09/25/15 11:02:04] [SSH] Starting sftp client.
[09/25/15 11:02:05] [SSH] Copying latest slave.jar...

[09/25/15 11:02:05] [SSH] Copied 489.023 bytes.
Expanded the channel window size to 4MB
[09/25/15 11:02:05] [SSH] Starting slave process: cd "./jenkins-slave" && java  -jar slave.jar

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

Is there any way to set the correct variables through Jenkins before (!) running java -jar slave.jar? I have tried setting the Environment variables in the Node Properties section of Jenkins, but they aren't applied prior to slave installation. (cf. this bugreport)

Only thing Jenkins should do prior to java -jar slave.jar is run the following:

JAVA_HOME=/opt/app/java17; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH

How can I do this?

Davor Josipovic
  • 754
  • 9
  • 21

2 Answers2

3

Found it.

You don't need any plugins (which do not work anyway) like some forum posts suggest. You only need to specify the JavaPath under the advanced properties of the credentials used to connect to the slave.

enter image description here

Davor Josipovic
  • 754
  • 9
  • 21
0

You can update your Jenkins version, it will solve it. Otherwise this worked for me (Jenkins 1.6, build/test node: macOS Mojave):

First install java8 in your build/test node using the commands:

brew update
brew cask install caskroom/versions/java8

Then in Jenkins web panel click on your build/test node, then click on Configure and then click in the Advanced... button, this will show you multiple text fields. Then in the JavaPath field add the path to your java8.

For me this path is like:

/Library/Java/JavaVirtualMachines/jdk1.8.X_XXX.jdk/Contents/Home/bin/java

Note: remember replace X_XXX with your java8 version before.

Then Save.

After that disconnect the build/test node and connect it again. This should solve the problem.

Source