diff --git a/jenkins-scripts/docker/lib/docker_generate_dockerfile.bash b/jenkins-scripts/docker/lib/docker_generate_dockerfile.bash index b8b36628a..151e092f8 100644 --- a/jenkins-scripts/docker/lib/docker_generate_dockerfile.bash +++ b/jenkins-scripts/docker/lib/docker_generate_dockerfile.bash @@ -411,6 +411,10 @@ echo '# END SECTION' BUILDSH_CCACHE fi +# In upstart jobs (Xenial) the USER variable is not set for the jenkins +# session. Fallback to get the user from processes table +USER=${USER:-$(ps -o user= -p $PPID)} + cat >> Dockerfile << DELIM_DOCKER_USER # Create a user with passwordless sudo ARG USERID