如何将流浪汉与詹金斯相结合,创造一个完美的持续整合环境?

你有一个需要运行一些 SW 需求的项目(例如: 一个特定版本的 Apache,一个 PHP 版本,一个 MySQL 数据库的实例和一些其他的软件)。

您已经发现了 流浪汉,因此您的虚拟环境已经全部设置好了。您可以使用配置文件和食谱创建框。

您还了解了持续集成系统(如 詹金斯)的优点。

现在,您希望将这两个世界(Vagrant 和 Jenkins)结合起来,以获得完美的持续集成环境。更具体地说,您不希望在运行 Jenkins 的机器上安装项目所需的 SW,但是您希望使用 Vagrant 提供的虚拟环境定期在其上构建项目。CI 软件(Jenkins)将为您构建流浪者盒子,并在其上构建和测试您的项目。

您将如何设置您的环境来实现这一点?

53840 次浏览

it is a good solution for build system, my suggestion:

  1. Your current jenkins works as master CI (probably started by user jenkins)
  2. Create another user in same machine or another machine to work as jenkins slave mode
    • jenkins slave can be invoked from jenkins master, and it can use different user like vagrant who had permission and environment for vagrant, therefore it will not interfere the original jenkins master server
    • create your base vagrant box, then it can be reused to speedup for your deployment
  3. Most of the installation information (packages) could be managed by puppet (or chef) to be loaded into your vm box.

Probably you can take a look at veewee, which can create vagrant box on fly.

Here is the Make CI easier with Jenkins CI and Vagrant for my guideline for this suggestion.

You could try the Vagrant Plugin for Jenkins that currently supports Jenkins CD 1.532.3

You can see a demo of this plugin running at http://unethicalblogger.com/2012/03/13/vagrant-plugin-in-action.html

Personally I'd suggest using Hashicorp Packer to build out your Vagrant boxes for developers, and then use it to also output a Docker or AWS or OpenStack image that you can run on your CI system. Vagrant is an awesome tool, but the overhead of VMs can be a little high for a CI system to constantly spin them up and down, especially if you want really fast feedback.

At a former client we basically booted the Vagrant machines once with the system, and then ran Docker/virtualenv builds inside of those VMs and we periodically destroyed them when there was a major upgrade or an issue with the environment not behaving correctly.

https://www.packer.io/docs/builders/openstack.html