Closed sharon-go closed 1 year ago
@sharon-go from what I can read, the error comes from your docker image so that means that the variable is not defined correctly in the environment inside the container. The fact that it is defined in your machine is irrelevant... unless you pass it on, which I wouldn't recommend because probably the path specified in that variable wouldn't be the same.
That said, assuming you are running the official and latest maven
image as mentioned, that variable is indeed defined when the image is created and it is propagated when running as well:
$ docker run --rm -ti maven:latest /bin/sh -c 'env | sort | grep JAVA'
JAVA_HOME=/opt/java/openjdk
JAVA_VERSION=jdk-17.0.5+8
I can duplicate the error if I replace the variable with another value:
$ docker run --rm -ti -e JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home maven
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
So the issue appears to be that either your docker compose file or your plugin's configuration is replacing the variable as it comes in the image to an invalid value :(
Hey,
Look like an issue in docker-maven https://github.com/carlossg/docker-maven/issues/282
I did try to run the mvn command using your example same issue: docker run --rm -ti maven:latest /bin/sh -c 'mvn --version' The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program.
docker run --rm -ti maven:latest /bin/sh -c 'env | sort | grep JAVA' JAVA_HOME=/opt/java/openjdk JAVA_VERSION=jdk-17.0.5+8
@sharon-go glad to know that it is a compatibility issue between the latest maven images and old docker daemons and not something in this plugin :)
Yes this is the issue :)
Thank you .
docker run --rm -ti maven:latest /bin/sh -c 'mvn --version' Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/share/maven Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.49-linuxkit", arch: "amd64", family: "unix"
Hey,
On my local server echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
docker-compose.yml version: "3" services: maven:
Run pre-built maven image from docker library
volumes: maven-repository:
pipeline.yml steps:
when trying to build my java project getting this error:
docker-compose -f .buildkite/docker-compose.yml -p buildkite0184627a9f4e4fc4b0452a9bdce7c59b run --name buildkite0184627a9f4e4fc4b0452a9bdce7c59b_maven_build_49 --rm maven /bin/sh -e -c 'mvn clean install -P local' The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program.
user command error: The plugin docker-compose command hook exited with status 1