Articles on: Refinery Runners for Jenkins

Standardised Java JDK Management for Jenkins Runners

Refinery Runners for Jenkins: Improved Java Version Support


We are updating the Jenkins Runners aka StackTrack Refinery Runners for Jenkins to improve how Java versions are managed across Jenkins controllers, agents, jobs, and pipelines.

This change gives teams more flexibility when selecting Java versions for build workloads, while helping us prepare the platform for future Jenkins and JDK upgrades with lower operational risk.

What is changing

Java version selection can now be controlled at multiple levels:

  • Controller level
  • Folder level
  • Job or pipeline level

We are also decoupling the Java runtime used by Jenkins agents from the Java version used inside build steps, including:

  • Pipeline sh commands
  • Freestyle job shell steps
  • Jobs that need a specific JDK version for compilation, testing, or tooling

This means Jenkins agents can run on the Java version required by the Jenkins platform, while individual jobs and pipelines can still use the Java version required by the application being built.


Previous iterations of our platform had some separation for the Java versions but we enabled you to also use the system Java installation and because of that we created a dependency between your builds and the system Java that impacted our ability to upgrade. This change overrides that behaviour.

Why this matters

This update helps teams:

  • Adopt newer Java versions in a controlled way
  • Continue supporting workloads that require older Java versions
  • Reduce risk during future Jenkins and JDK upgrades
  • Avoid coupling Jenkins platform upgrades to every application build requirement
  • Give individual teams more control over the Java version used by their jobs and pipelines

Impact

This is a non-disruptive change.

There is no expected downtime and no expected impact to running jobs or pipelines.

Existing configurations will continue to work as they do today unless a Java version is explicitly overridden.

For managed Jenkins agents, StackTrack will ensure the Jenkins agent runtime uses a supported Java version for the Jenkins platform. For Jenkins LTS 2.555.1 and later, Jenkins requires Java 21 or Java 25 on both the controller JVM and agent JVMs. (Jenkins)

Selecting a Java version in jobs and pipelines

Once this change is enabled, customers can select the Java version used by their jobs or pipelines by setting the JENV_VERSION environment variable.

Java Version

JENV_VERSION value

JAVA_HOME

Java 6

1.6

/usr/lib/jvm/jdk-1.6

Java 7

1.7

/usr/lib/jvm/jdk-1.7

Java 8

1.8

/usr/lib/jvm/jdk-1.8

Java 11

11

/usr/lib/jvm/jdk-11

Java 17

17

/usr/lib/jvm/jdk-17

Java 21 — default

21

/usr/lib/jvm/jdk-21

Java 25

25

/usr/lib/jvm/jdk-25

Example:

pipeline {
agent any

environment {
JENV_VERSION = '17'
}

stages {
stage('Check Java version') {
steps {
sh 'java -version'
}
}
}
}

Using Jenkins JDK tools

Customers can also use Jenkins JDK tools instead of setting JENV_VERSION directly.

JDK Tool Name

JAVA_HOME

Declarative Pipeline

Scripted Pipeline

JDK1.6

/usr/lib/jvm/jdk-1.6

tools { jdk 'JDK1.6' }

def javaHome = tool 'JDK1.6'env.JAVA_HOME = javaHome

JDK1.7

/usr/lib/jvm/jdk-1.7

tools { jdk 'JDK1.7' }

def javaHome = tool 'JDK1.7'env.JAVA_HOME = javaHome

JDK1.8

/usr/lib/jvm/jdk-1.8

tools { jdk 'JDK1.8' }

def javaHome = tool 'JDK1.8'env.JAVA_HOME = javaHome

JDK11

/usr/lib/jvm/jdk-11

tools { jdk 'JDK11' }

def javaHome = tool 'JDK11'env.JAVA_HOME = javaHome

JDK17

/usr/lib/jvm/jdk-17

tools { jdk 'JDK17' }

def javaHome = tool 'JDK17'env.JAVA_HOME = javaHome

JDK21

/usr/lib/jvm/jdk-21

tools { jdk 'JDK21' }

def javaHome = tool 'JDK21'env.JAVA_HOME = javaHome

JDK25

/usr/lib/jvm/jdk-25

tools { jdk 'JDK25' }

def javaHome = tool 'JDK25'env.JAVA_HOME = javaHome

Example declarative pipeline:

pipeline {
agent any

tools {
jdk 'JDK21'
}

stages {
stage('Check Java version') {
steps {
sh 'java -version'
}
}
}
}

Example scripted pipeline:

node {
def javaHome = tool 'JDK21'
env.JAVA_HOME = javaHome
env.PATH = "${javaHome}/bin:${env.PATH}"

sh 'java -version'
}


Customers with permanent agents

Customers who own or manage their own permanent Jenkins agents must ensure those agents are upgraded to Java 21 or Java 25 before moving to Jenkins LTS 2.555.1 or later.

From Jenkins LTS 2.555.1, Java 21 or Java 25 is required for both the Jenkins controller and agent JVMs. Java 17 is not supported for Jenkins 2.555.1 and later. (Jenkins)

This does not prevent jobs from using older Java versions for build steps where required.


The Jenkins agent runtime and the Java version used inside a job or pipeline can now be managed separately.

Updated on: 29/04/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!