zhuce 发表于 2018-1-11 19:36:29

Docker连接General Version Control System(Gitlab/Github)自动build

  由于官方只支持Docker连接Github的自动build,那么我们使用其他version control(如Gitlab,CVS等)的同学们应该怎么做呢。
  博主使用的方案是jenkins+jenkins提供的docker插件。
  需要用到DooD (Docker-outside-of-Docker) 或者DinD(Docker-in-Docker)技术。
  具体参照:
  http://container-solutions.com/running-docker-in-jenkins-in-docker/
  在jenkins容器可以访问docker命令完成以后,继续安装相关jenkins上的docker插件来完成gitlab上docker的自动build过程。
  本文中使用的docker相关插件包括以下五个(参考文章http://www.iyunv.com/Linux/2015-07/120287.htm):

[*]CloudBees Docker Build and Publish plugin — This plugin provides the ability to build projects with a Dockerfile, and publish the resultant tagged image (repo) to the docker registry.
[*]Docker build step plugin — This plugin allows to add various Docker commands into you job as a build step.
[*]Docker Plugin — This plugin allows slaves to be dynamically provisioned using Docker.
[*]Kubernetes Plugin — This plugin allows slaves to be dynamically provisioned on multiple Docker hosts using Kubernetes.
[*]Docker Commons Plugin — APIs for using Docker from other plugins.
  其中,它们间的关系如下:

[*]Docker commons Plugin为其他与Docker相关的插件提供了APIs
[*]CloudBees Docker Build and Publish plugin和Docker build step plugin都依赖了Docker commons Plugin
[*]Kubernetes Plugin依赖了Docker Plugin
  坑:
http://www.cnblogs.com/download/attachments/2137092/image2016-7-25%2018%3A1%3A48.png?version=1&modificationDate=1469440803000&api=v2
  在上图kitematic界面中点击右下侧任意一个路径,会弹出如图对话框,若选择Enable Volumes会发生四件坏事:
  1.强制重启jenkins server,即便有job没有完成;
  2.重启后需要重新安装jenkins插件;
  3.导致jenkins无法使用DooD的docker命令。
  3.admin用户的密码会改变。
  所以切记任何时候使用jenkins容器不要点选enable volumes。
  解决办法:
  停止(删除)docker,重新运行以下命令并配置新的jenkins容器。
  docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):/usr/bin/docker -p 8080:8080 myjenk
页: [1]
查看完整版本: Docker连接General Version Control System(Gitlab/Github)自动build