Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40684

Can't add a shell build step with docker

XMLWordPrintable

      Host is a debian 8.4 server

      Jenkins is contenerised and launched with

      docker run -d --name myjenkins -p 9090:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /var/jenkins_home:/var/jenkins_home --restart="always" myjenk
      

      from the dockerfile

      FROM jenkins:latest
      
      USER root
      RUN apt-get update \
            && apt-get install -y sudo \
            && rm -rf /var/lib/apt/lists/*
      RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers
      

      I have a simple build configured as such:

      the build Dockerfile being

      FROM node:latest
      
      MAINTAINER Poirey Nicolas <fake@mail.com>
      
      WORKDIR /16AGR/frontend
      
      EXPOSE 8080
      CMD [ "npm", "install" ]
      

      IĀ get this error:

      Started by user admin
      Building in workspace /var/jenkins_home/workspace/frontend-unit-test-2
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url https://github.com/npoirey/16AGR.git # timeout=10
      Fetching upstream changes from https://github.com/npoirey/16AGR.git
       > git --version # timeout=10
       > git fetch --tags --progress https://github.com/npoirey/16AGR.git +refs/heads/*:refs/remotes/origin/*
       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
      Checking out Revision bb7291657427c118a5df4d97d070a7abb90f8f06 (refs/remotes/origin/master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f bb7291657427c118a5df4d97d070a7abb90f8f06
       > git rev-list bb7291657427c118a5df4d97d070a7abb90f8f06 # timeout=10
      Build Docker image from ./frontend//Dockerfile ...
      $ docker build --file /var/jenkins_home/workspace/frontend-unit-test-2/frontend/Dockerfile /var/jenkins_home/workspace/frontend-unit-test-2/frontend
      Sending build context to Docker daemon 93.18 kB
      
      Step 1 : FROM node:latest
       ---> d1699fb7d2bf
      Step 2 : MAINTAINER Poirey Nicolas <fake@mail.com>
       ---> Using cache
       ---> 787f355d0144
      Step 3 : WORKDIR /16AGR/frontend
       ---> Using cache
       ---> 083aa873e30a
      Step 4 : EXPOSE 8080
       ---> Using cache
       ---> 53eb0ed184a9
      Step 5 : CMD npm install
       ---> Using cache
       ---> 2917019ab455
      Successfully built 2917019ab455
      $ docker run --rm --entrypoint /bin/true alpine:3.2
      $ docker run --tty --rm --entrypoint /sbin/ip alpine:3.2 route
      $ docker run --tty --detach --privileged --workdir /var/jenkins_home/workspace/frontend-unit-test-2 --volume /var/jenkins_home:/var/jenkins_home:rw --volume /tmp:/tmp:rw --net bridge --add-host dockerhost:172.17.0.1 --env BUILD_DISPLAY_NAME=#4 --env BUILD_ID=4 --env BUILD_NUMBER=4 --env BUILD_TAG=jenkins-frontend-unit-test-2-4 --env CLASSPATH= --env EXECUTOR_NUMBER=1 --env GIT_BRANCH=origin/master --env GIT_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 --env GIT_PREVIOUS_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 --env GIT_PREVIOUS_SUCCESSFUL_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 --env GIT_URL=https://github.com/npoirey/16AGR.git --env HUDSON_HOME=/var/jenkins_home --env HUDSON_SERVER_COOKIE=23e53af9086f2739 --env JENKINS_SERVER_COOKIE=23e53af9086f2739 --env JOB_BASE_NAME=frontend-unit-test-2 --env JOB_NAME=frontend-unit-test-2 --env NODE_LABELS=master --env NODE_NAME=master --env WORKSPACE=/var/jenkins_home/workspace/frontend-unit-test-2 2917019ab455 /bin/cat
      Docker container fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109 started to host the build
      $ docker exec --tty fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109 env
      [frontend-unit-test-2] $ docker exec --tty --user 0:0 fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109 env BUILD_DISPLAY_NAME=#4 BUILD_ID=4 BUILD_NUMBER=4 BUILD_TAG=jenkins-frontend-unit-test-2-4 CLASSPATH= EXECUTOR_NUMBER=1 GIT_BRANCH=origin/master GIT_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 GIT_PREVIOUS_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 GIT_PREVIOUS_SUCCESSFUL_COMMIT=bb7291657427c118a5df4d97d070a7abb90f8f06 GIT_URL=https://github.com/npoirey/16AGR.git HOME=/root HOSTNAME=fe9a8942f1d9 HUDSON_HOME=/var/jenkins_home HUDSON_SERVER_COOKIE=23e53af9086f2739 JENKINS_SERVER_COOKIE=23e53af9086f2739 JOB_BASE_NAME=frontend-unit-test-2 JOB_NAME=frontend-unit-test-2 NODE_LABELS=master NODE_NAME=master NODE_VERSION=7.3.0 NPM_CONFIG_LOGLEVEL=info PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TERM=xterm WORKSPACE=/var/jenkins_home/workspace/frontend-unit-test-2 /bin/sh -xe /tmp/hudson178227185989971526.sh
      /bin/sh: 0: Can't open /tmp/hudson178227185989971526.sh
      Build step 'Execute shell' marked build as failure
      Stopping Docker container after build completion
      $ docker kill fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109
      fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109
      $ docker rm --force fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109
      fe9a8942f1d9665a799c90ee796cdc47dcb73c1bfaf4bd09c515bc1ddb509109
      Finished: FAILURE
      

      If I remove the build step no error is thown

            Unassigned Unassigned
            sacapuces Nicolas Poirey
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: