我正在尝试在Jenkins Shell中运行docker命令
我正在尝试的命令shell是
# optional: record current versions of docker apps with each build
docker -v && docker-compose -v && docker-machine -v
# set-up: clean up any previous machine failures
docker-machine stop test || echo "nothing to stop" && \
docker-machine rm test || echo "nothing to remove"
# use docker-machine to create and configure 'test' environment
# add a -D (debug) if having issues
docker-machine create --driver virtualbox test
eval "$(docker-machine env test)"
# use docker-compose to pull and build new images and containers
docker-compose -p jenkins up -d
# optional: list machines, images, and containers
docker-machine ls && docker images && docker ps -a
# wait for containers to fully start before tests fire up
sleep 30
# test services
sh tests.sh $(docker-machine ip test)
# tear down: stop and remove 'test' environment
#docker-machine stop test && docker-machine rm test
有谁知道如何设置Jenkins来运行docker命令(docker
,docker-compose
和docker-machine
)?
更新(错误讯息)
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/Virtual-Vehicles_Docker_Machine/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/garystafford/virtual-vehicles-docker.git # timeout=10
Fetching upstream changes from https://github.com/garystafford/virtual-vehicles-docker.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress https://github.com/garystafford/virtual-vehicles-docker.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 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5
> git rev-list 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5 # timeout=10
[workspace] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh
+ docker -v
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 3: docker: command not found
+ docker-machine stop test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 6: docker-machine: command not found
+ echo 'nothing to stop'
nothing to stop
+ docker-machine rm test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 7: docker-machine: command not found
+ echo 'nothing to remove'
nothing to remove
+ docker-machine create --driver virtualbox test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 11: docker-machine: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
命令 docker version
Client:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 22:37:33 2016
OS/Arch: darwin/amd64
Server:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 22:37:33 2016
OS/Arch: linux/amd64
命令 docker-compose -v
docker-compose version 1.6.0, build d99cad6
命令 docker-machine -v
docker-machine version 0.6.0, build e27fb87
答案 0 :(得分:-1)
docker适用于Jenkins。
最重要的是,确保在Jenkins构建从站上安装了正确版本的docker和docker-compose(如果需要)。
确保jenkins用户是Jenkins构建slave的docker组的一部分。
然后你可以照常执行docker命令。