docker-maven icon indicating copy to clipboard operation
docker-maven copied to clipboard

Better user spoofing

Open mikeslattery opened this issue 6 years ago • 0 comments

Jenkins uses container images such as this as build agents. Jenkins partially spoofs the "jenkins" user by setting the UID and passing along environmental variables. This image would be more useful in that case if it helped also with spoofing the users's HOME directory, as follows in mvn-entrypoint.sh:

export JAVA_OPTS="-Duser.home='$HOME' ${JAVA_OPTS:-}"
export MAVEN_OPTS="-Duser.home='$HOME' ${MAVEN_OPTS:-}"
export MAVEN_CONFIG="${HOME}/.m2"

A Jenkinsfile would only need:

agent { docker { image "maven"; args "-e HOME=$HOME" }}

If this is desirable, I can create a pull request.

Side notes:

  • OpenJDK System.c gets the default value for user.home directly from the /etc/passwd file
  • By default, Maven locates the .m2 directory based on the user.home property.

mikeslattery avatar Oct 29 '18 18:10 mikeslattery