From: Wesley Hirsch Date: Fri, 8 Sep 2017 21:50:38 +0000 (-0400) Subject: Add Jenkins user to Docker image earlier X-Git-Tag: v3.0.0rc~13 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=dda707b51e8ce223a59d454dbd3f5a43f212b2ac;p=osm%2Fdevops.git Add Jenkins user to Docker image earlier Docker Setup stage fails with a permissions error if run in the existing manner. This appends the user creation to the Dockerfile so that the commands get run as root. Change-Id: Ib9deee967586792e8c932c875a34bd3ff5aec918 Signed-off-by: Wesley Hirsch --- diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 45cbc7d6..45bf777e 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -45,16 +45,12 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system) { container_name = "${project}-${branch}".toLowerCase() stage('Docker-Build') { + sh "echo 'RUN groupadd -o -g " + "id -g".execute().text + " -r jenkins \\' >> Dockerfile" + sh "echo ' && useradd -o -u " + "id -u".execute().text + " --create-home -r -g jenkins jenkins' >> Dockerfile" sh "docker build -t ${container_name} ." } withDockerContainer("${container_name}") { - stage('Docker-Setup') { - sh ''' - groupadd -o -g $(id -g) -r jenkins - useradd -o -u $(id -u) --create-home -r -g jenkins jenkins - ''' - } stage('Test') { sh 'devops-stages/stage-test.sh' }