From 1b3616e68408a881df58e1bb806bc9c78828f779 Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Wed, 27 Jun 2018 11:13:06 +0200 Subject: Create a user with correct uid inside CI's Dockerfile --- scripts/ci/Dockerfile.bitbake | 5 +++++ scripts/ci/Jenkinsfile.bleeding | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'scripts/ci') diff --git a/scripts/ci/Dockerfile.bitbake b/scripts/ci/Dockerfile.bitbake index 9d34dca..c91f94c 100644 --- a/scripts/ci/Dockerfile.bitbake +++ b/scripts/ci/Dockerfile.bitbake @@ -31,6 +31,11 @@ RUN apt-get update -q && apt-get install -qy \ xterm \ xz-utils +ARG uid=1000 +ARG gid=1000 +RUN groupadd -g $gid bitbake +RUN useradd -m -u $uid -g $gid bitbake + RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen ENV LC_ALL="en_US.UTF-8" ENV LANG="en_US.UTF-8" diff --git a/scripts/ci/Jenkinsfile.bleeding b/scripts/ci/Jenkinsfile.bleeding index f4d8883..e50b4b6 100644 --- a/scripts/ci/Jenkinsfile.bleeding +++ b/scripts/ci/Jenkinsfile.bleeding @@ -1,8 +1,16 @@ // This CI setup checks out aktualizr, meta-updater and updater-repo and builds // master branches whenever a change is pushed to any of these +// define these for docker image creation +node { + // might cause some problems: + // https://stackoverflow.com/questions/44805076/setting-build-args-for-dockerfile-agent-using-a-jenkins-declarative-pipeline + JENKINS_UID = sh(returnStdout: true, script: 'id -u').trim() + JENKINS_GID = sh(returnStdout: true, script: 'id -g').trim() +} + pipeline { - agent none + agent any environment { TEST_AKTUALIZR_REMOTE = 'aktualizr' TEST_AKTUALIZR_DIR = 'aktualizr' @@ -11,8 +19,8 @@ pipeline { } stages { stage('checkout') { - agent any steps { + checkout([$class: 'GitSCM', userRemoteConfigs: [ [url: 'https://github.com/advancedtelematic/aktualizr', name: 'aktualizr'] @@ -61,6 +69,8 @@ pipeline { dockerfile { filename 'scripts/ci/Dockerfile.bitbake' args '-v /opt/jenkins/bitbake-common:/opt/jenkins/bitbake-common' + additionalBuildArgs "--build-arg uid=${JENKINS_UID} --build-arg gid=${JENKINS_GID}" + reuseNode true } } environment { -- cgit v1.2.3-54-g00ecf