我想在Jenkins上运行docker文件,并执行作业中的shell脚本,我找到了plugin:docker slaves插件,但似乎不起作用,任何人都有更好的建议或如何正确使用该插件?,谢谢! !
You can run bash script under Build -> Execute shell . If you are interested to docker container using Jenkins you can utilize the Execute Shell option. But make sure Jenkins have access to Docker.
cd /path_to_you_docker_file/
echo "building docker image for"
docker built -t alpine .
echo "starting alpien container"
docker run --name alpine -dit alpine
echo "All running containers in Jenkins servers"
docker ps
You can execute multiple Shell in build section.
You will see the container in Jenkins name alpine.
The plugin can be used better with pipeline, not with a bash script.
docker.image('ruby:2.3.1').inside {
stage("Install Bundler") {
sh "gem install bundler --no-rdoc --no-ri"
}
stage("Use Bundler to install dependencies") {
sh "bundle install"
}
}
To run with the plugin you can check this article to configure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.