无法在容器化的Jenkins上添加带有docker的shell构建步骤

时间:2016-12-27 20:14:08

标签: jenkins docker jenkins-plugins

Host是debian 8.4服务器

詹金斯是集装箱化并随

一起推出
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
来自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

我有一个简单的构建配置如下: build configuration

构建Dockerfile

FROM node:latest

MAINTAINER Poirey Nicolas <fake@mail.com>

WORKDIR /16AGR/frontend

EXPOSE 8080
CMD [ "npm", "install" ]

我收到此错误:

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

如果删除构建步骤,则不会出现错误

我真的不明白我做错了什么:(

0 个答案:

没有答案