Issue
You want to use Zulu® (Multi-platform Certified OpenJDK™) in a job and want to let Jenkins install it automatically on a linux agent
Environment
-
Linux 64bits executors (The script can be updated to manage others platforms)
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees Jenkins Enterprise - Managed controller
-
Jenkins
Resolution
To install Zulu 8.23.0.3 (JDK 1.8.0_144), in your Jenkins configuration screen, you have to add a new JDK Installation using a shell script to install automatically it.

Here is the script used to install the version 8.23.0.3 (JDK 1.8.0_144). Depending of the version you want to install you may have to update the version and jdkUrl variables.
Tool Home must be the archive name without the extension (it is the directory name within the archive). In this case it will be zulu8.23.0.3-jdk8.0.144-linux_x64
.
#!/bin/bash -ue version=8.23.0.3 jdkUrl=https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz jdkArchive=$(basename $jdkUrl) jdkName="${jdkArchive%.tar.gz}" jdkDir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" thisJdkDir=${jdkDir}/${jdkName} if ! type wget >/dev/null 2>&1; then echo "ERROR: Unable to run wget" exit 1 fi if [ -x $thisJdkDir/bin/java ]; then JAVA_HOME="$thisJdkDir" if $JAVA_HOME/bin/java -version 2>&1 | grep -q "$version"; then exit 0 fi fi echo "Installing Zulu ${version} in ${thisJdkDir}" rm -rf $thisJdkDir wget --no-verbose --referer=https://www.azulsystems.com/products/zulu/downloads $jdkUrl -O ${jdkArchive} tar -xf ${jdkArchive} rm -f ${jdkArchive} echo "Zulu ${version} installed in ${thisJdkDir}" exit 0
For example if you use it with Apache Maven it will give you something like
[zulu] $ mvn --version Apache Maven 3.5.1 (094e4e31a5af55bb17be87675da41d9aeca062f3; 2017-09-10T08:42:54-04:00) Maven home: /scratch/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.1/apache-maven-3.5.1 Java version: 1.8.0_144, vendor: Azul Systems, Inc. Java home: /scratch/jenkins/tools/hudson.model.JDK/Zulu8/zulu8.23.0.3-jdk8.0.144-linux_x64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-129-generic", arch: "amd64", family: "unix"