gpt4 book ai didi

jenkins - 在Jenkins Shell中运行Docker命令

转载 作者:行者123 更新时间:2023-12-02 20:31:58 27 4
gpt4 key购买 nike

我正在尝试在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命令( dockerdocker-composedocker-machine)?

UPDATE(错误消息)
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版本
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

最佳答案

docker 与 Jenkins 一起工作。

最重要的是,确保在Jenkins build slave上安装了正确版本的docker和docker-compose(如果需要)。

确保jenkins用户是Jenkins构建从属服务器上的docker组的一部分。

然后,您可以照常执行docker命令。

关于jenkins - 在Jenkins Shell中运行Docker命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36297959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com