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

Can't add a shell build step with docker

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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

        Attachments

          Activity

          Hide
          wanglibao1989 wang libao added a comment -

          I'v run into the same problem,here is the log

           
          $ docker run --rm --entrypoint /bin/true alpine:3.6
          $ docker run --tty --rm --entrypoint /sbin/ip alpine:3.6 route
          $ docker run --tty --detach --workdir /home/q/workspace/docker_test_job --volume /home/q:/home/q:rw --volume /tmp:/tmp:rw --net bridge --add-host dockerhost:172.17.0.1 --env BUILD_DISPLAY_NAME=#18 --env BUILD_ID=18 --env BUILD_NUMBER=18 --env BUILD_TAG=jenkins-docker_test_job-18 --env BUILD_URL=
          http://localhost:8080/job/docker_test_job/18/
          --env CLASSPATH= --env EXECUTOR_NUMBER=0 --env "HUDSON_HOME=C:\Program Files (x86)\Jenkins" --env HUDSON_SERVER_COOKIE=8431b78f294fa38a --env HUDSON_URL=
          http://localhost:8080/
          --env "JENKINS_HOME=C:\Program Files (x86)\Jenkins" --env JENKINS_SERVER_COOKIE=8431b78f294fa38a --env JENKINS_URL=
          http://localhost:8080/
          --env JOB_BASE_NAME=docker_test_job --env JOB_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/display/redirect
          --env JOB_NAME=docker_test_job --env JOB_URL=
          http://localhost:8080/job/docker_test_job/
          --env NODE_LABELS=docker_test --env NODE_NAME=docker_test --env RUN_CHANGES_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/18/display/redirect?page=changes
          --env RUN_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/18/display/redirect
          --env WORKSPACE=/home/q/workspace/docker_test_job a7dc1a88f751 /bin/cat
          Docker container 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 started to host the build
          $ docker exec --tty 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 env
          [docker_test_job] $ docker exec --tty --user 1000:1000 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 env BUILD_DISPLAY_NAME=#18 BUILD_ID=18 BUILD_NUMBER=18 BUILD_TAG=jenkins-docker_test_job-18 BUILD_URL=
          http://localhost:8080/job/docker_test_job/18/
          CLASSPATH= EXECUTOR_NUMBER=0 HOME=/root HOSTNAME=526c98683c7a "HUDSON_HOME=C:\Program Files (x86)\Jenkins" HUDSON_SERVER_COOKIE=8431b78f294fa38a HUDSON_URL=
          http://localhost:8080/
          "JENKINS_HOME=C:\Program Files (x86)\Jenkins" JENKINS_SERVER_COOKIE=8431b78f294fa38a JENKINS_URL=
          http://localhost:8080/
          JOB_BASE_NAME=docker_test_job JOB_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/display/redirect
          JOB_NAME=docker_test_job JOB_URL=
          http://localhost:8080/job/docker_test_job/
          LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 NODE_LABELS=docker_test NODE_NAME=docker_test PATH=$PATH:/snap/bin RUN_CHANGES_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/18/display/redirect?page=changes
          RUN_DISPLAY_URL=
          http://localhost:8080/job/docker_test_job/18/display/redirect
          TERM=xterm WORKSPACE=/home/q/workspace/docker_test_job /bin/bash /tmp/jenkins1469389118824566527.sh
          /bin/bash: /tmp/jenkins1469389118824566527.sh: No such file or directory
           

           

          Show
          wanglibao1989 wang libao added a comment - I'v run into the same problem,here is the log   $ docker run --rm --entrypoint /bin/true alpine:3.6 $ docker run --tty --rm --entrypoint /sbin/ip alpine:3.6 route $ docker run --tty --detach --workdir /home/q/workspace/docker_test_job --volume /home/q:/home/q:rw --volume /tmp:/tmp:rw --net bridge --add-host dockerhost:172.17.0.1 --env BUILD_DISPLAY_NAME=#18 --env BUILD_ID=18 --env BUILD_NUMBER=18 --env BUILD_TAG=jenkins-docker_test_job-18 --env BUILD_URL= http://localhost:8080/job/docker_test_job/18/ --env CLASSPATH= --env EXECUTOR_NUMBER=0 --env "HUDSON_HOME=C:\Program Files (x86)\Jenkins" --env HUDSON_SERVER_COOKIE=8431b78f294fa38a --env HUDSON_URL= http://localhost:8080/ --env "JENKINS_HOME=C:\Program Files (x86)\Jenkins" --env JENKINS_SERVER_COOKIE=8431b78f294fa38a --env JENKINS_URL= http://localhost:8080/ --env JOB_BASE_NAME=docker_test_job --env JOB_DISPLAY_URL= http://localhost:8080/job/docker_test_job/display/redirect --env JOB_NAME=docker_test_job --env JOB_URL= http://localhost:8080/job/docker_test_job/ --env NODE_LABELS=docker_test --env NODE_NAME=docker_test --env RUN_CHANGES_DISPLAY_URL= http://localhost:8080/job/docker_test_job/18/display/redirect?page=changes --env RUN_DISPLAY_URL= http://localhost:8080/job/docker_test_job/18/display/redirect --env WORKSPACE=/home/q/workspace/docker_test_job a7dc1a88f751 /bin/cat Docker container 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 started to host the build $ docker exec --tty 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 env [docker_test_job] $ docker exec --tty --user 1000:1000 526c98683c7a64d4f5998f6f9d5eac90450e46cccea51d557ae4b5268437dec6 env BUILD_DISPLAY_NAME=#18 BUILD_ID=18 BUILD_NUMBER=18 BUILD_TAG=jenkins-docker_test_job-18 BUILD_URL= http://localhost:8080/job/docker_test_job/18/ CLASSPATH= EXECUTOR_NUMBER=0 HOME=/root HOSTNAME=526c98683c7a "HUDSON_HOME=C:\Program Files (x86)\Jenkins" HUDSON_SERVER_COOKIE=8431b78f294fa38a HUDSON_URL= http://localhost:8080/ "JENKINS_HOME=C:\Program Files (x86)\Jenkins" JENKINS_SERVER_COOKIE=8431b78f294fa38a JENKINS_URL= http://localhost:8080/ JOB_BASE_NAME=docker_test_job JOB_DISPLAY_URL= http://localhost:8080/job/docker_test_job/display/redirect JOB_NAME=docker_test_job JOB_URL= http://localhost:8080/job/docker_test_job/ LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 NODE_LABELS=docker_test NODE_NAME=docker_test PATH=$PATH:/snap/bin RUN_CHANGES_DISPLAY_URL= http://localhost:8080/job/docker_test_job/18/display/redirect?page=changes RUN_DISPLAY_URL= http://localhost:8080/job/docker_test_job/18/display/redirect TERM=xterm WORKSPACE=/home/q/workspace/docker_test_job /bin/bash /tmp/jenkins1469389118824566527.sh /bin/bash: /tmp/jenkins1469389118824566527.sh: No such file or directory    

            People

            • Assignee:
              Unassigned
              Reporter:
              sacapuces Nicolas Poirey
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: