JAVA_HOME undefined calling docker run only when running from Jenkins

Hey all,

I have a Jenkins job which runs a docker image, the job started failing recently with The JAVA_HOME environment variable is not defined correctly, ... however when I run the image locally it’s absolutely fine any idea what the problem is?

We’re on Jenkins 2.263.4, with the node using Java 8

This is the failing stage in the Jenkins job …

sh '''#!/bin/bash
docker run --name container_name -v "$(pwd)":/data maven:latest

Hello @MercilessWinna and welcome to this community! :wave:

I see you’re referencing maven:latest.

It’s not always a good idea to use latest, as you never really know what changes are hiding inside… What version of Java is it using, on what operating system, and with which version of Maven? Only the people building it know…

If you have not made a docker pull on the two machines, you don’t know if you’re running the same image…

Better pin the maven image version, and then use a tool such a dependabot, renovate bot or updatecli to keep it updated if needed.

My $0.02.