用持续集成工具Travis进行构建和部署_项目管理_非技术区_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 非技术区 > 项目管理 > 用持续集成工具Travis进行构建和部署

用持续集成工具Travis进行构建和部署

 2014/11/29 9:59:47  Black Puppy  程序员俱乐部  我要评论(0)
  • 摘要:用持续集成工具Travis进行构建和部署摘要:本文简单说明了如何使用持续集成工具Travis进行构建和部署的过程。1.概述持续集成(ContinuousIntegration)是软件开发过程中的重要环节,不论是在开发环境,还是生产环境,其好处都是可以让团队尽快得到反馈,从而尽早发现和解决问题,不要等到用户来报告问题,影响产品和团队的声誉。越早越快地发现和解决问题,成本越低,这也是敏捷开发的基本目的之一。持续集成的工具有不少,著名的有CruiseControl
  • 标签:工具

用持续集成工具Travis进行构建和部署

摘要:本文简单说明了如何使用持续集成工具Travis进行构建和部署的过程。

1. 概述

持续集成(Continuous Integration)是软件开发过程中的重要环节,不论是在开发环境,还是生产环境,其好处都是可以让团队尽快得到反馈,从而尽早发现和解决问题,不要等到用户来报告问题,影响产品和团队的声誉。越早越快地发现和解决问题,成本越低,这也是敏捷开发的基本目的之一。

持续集成的工具有不少,著名的有CruiseControl、JetBrains的TeamCity、微软的Team Foundation Server。本文讲的是另外一个相对轻巧的持续集成工具Travis。这个工具的不同之处是,它已经搭建好了,有自己的环境,省去了你用自己的服务器安装、配置的麻烦。如果你的项目是开源的,只需要在https://travis-ci.org/上用Github的账号注册就可以免费使用了;如果不是开源的项目,就要收费了,要用https://travis-ci.com/,具体的收费标准可以参考https://travis-ci.com/plans。下面只讲述https://travis-ci.org/的使用和配置,因为https://travis-ci.com/我也没用过,不过估计收费的功能应该更多更好一些。

2. 选择项目

在https://travis-ci.org/注册了账号之后,在Github账号下的项目会自动出现在这里,可以选择哪个项目要用Travis来做持续集成,缺省情况下所有项目都是不做持续集成的。如下图所示,

JSIW8AgOoz17fNs2/q/TDVJQ4Cxyti1ptt7VYj0CcZms5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+fr4AeafvrA2HQ+1t83QsXakdeV9FeVt/m161fy6GEEKqnuQ9c/luuR3+zjsP8tYzqbzT8XDGsQkhZPo8f/784OAg/3vuoiDvPOstb0IIIesT5J0HeRNCCPEjyDsP8iaEEOJHnjx58vFnmyuU9593Dv730aMlmPvw4aM/7xx8/Nnmo8fHzqpA3oQQQvzID537X/zl2xXK+z9u/Fe4d/uP3+4uOuHe7f//xZ+/+Mu39zr3nVWBvAkhhPiR1+cXT548+dPNW6vtfy8hH3+2+cVfvn3y5MnLn86dVYG8CSGEeJPX5xc/dO6fnJz0T0/XOI8ePb7XuV9k7vfImxBCCPEuyJsQQgjxLMibEEII8SzImxBCCPEsi5X3MwAAAJg3i5X31GsAAACAIpA3AACAZyBvAAAAz0DeAAAAnoG8AQAAPAN5AwAAeMZi5U0IIYSQxQV5E0IIIZ4FeRNCCCGeZZ7yBgAAgJWAvAEAADwDeQMAAHgG8gYAAPAM5A0AAOAZ/wfaY7sWxJECbwAAAABJRU5ErkJggg==" alt="" />

3个项目中,只有最后一个项目是要做持续集成的,其它都不做持续集成。你还可以进一步配置,一个项目中的哪个或哪几个分支要做持续集成,这在后面会讲到。

3. 配置

持续集成的配置,必须通过位于项目根目录下的.travis.yml文件来进行,完整的文档可以见附录中的参考资料[1]。

首先,要选择项目的语言。写此文时Travis支持15种编程语言,象常用的Java、C、C++、JavasScript (with Node.js)、Objective-C、PHP、Python和Ruby都在支持之列。我的docs项目是个文档项目,使用Sphinx,所以语言就选择了Python 2.7,和我的开发环境保持一致。所以,我的.travis.yml文件开始的部分是这样的:

language: python
python:
  - "2.7"

其次,要安装一些相关的软件包,可以在install命令中进行安装,在安装之前必要的依赖包可以在before_install中进行,所以.travis.yml文件中相应的部分为:

# Use this to prepare the system to install prerequisites or dependencies
before_install: "sudo apt-get update"

# command to install dependencies
install: "pip install -q -r requirements.txt --use-mirrors"

而要安装的包是在requirements.txt中指定的,其内容如下:

Sphinx==1.2
sphinxcontrib-phpdomain

安装的Sphinx版本为1.2,最新的Sphinx 1.3在构建的时候会碰到错误,所以用旧一些的版本。sphinxcontrib-phpdomain是用来扩展Sphinx的。

4. 构建

构建在script命令中指定。在我的这个项目中,这是最简单的,我参考的资料也是最简单的,见[2]。.travis.yml文件中相应的部分为:

# command to build
script: make html

这里执行的命令,如果返回值是0就算成功,否则就算失败,这是Unix返回值的标准。

前面提到限制项目的分支,可以作如下配置:

# whitelist
branches:
  only:
    - mybranch

 这就是,只有mybranch这个分支要做持续集成,也可以用多行指定多个分支。

这时,就可以提交.travis.yml,并推送到Github服务器,Travis就会自动检查到这个项目的变化,自动启动一个虚拟机,来进行持续集成。

可以看到,这是一种按需、即时的方式,和自己安装、配置服务器进行持续集成的方式相比,更为节省资源,更能实现更好的效果。

5. 部署

部署稍微麻烦一些,因为要涉及到具体的服务器配置。相关的文档见参考资料[3]。

首先,Travis不支持sftp,详见考资料[4],这比较遗憾。为保证安全,我打算用ftps。

5.1 安装、配置服务器上的ftp

先要在服务器(Ubuntu 12.04)上安装、配置vsftpd,请看参考资料[7]和[8]。

但使用的是普通用户,不是超级管理员,也没有sudo的权限。要赋予该用户sudo的权限,可以把该用户加入sudo用户组。见参考资料[5]和[6],使用超级管理员root,执行如下命令:

# sudo usermod -a -G sudo myusername

这就把用户myusername加入了sudo用户组,就可以使用sudo来执行超级管理员才能的一些管理任务了,以下命令都是该普通用户执行的。

下面安装vsftpd,执行如下命令:

$ sudo apt-get install vsftpd

安装完毕后,配置vsftpd,这都是通过修改/etc/vsftpd.conf完成的。先禁止匿名用户:

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO

再允许服务器的本地用户(即myusername等)使用ftp:

# Uncomment this to allow local users to log in.
local_enable=YES

因为是要上传构建得到的文件到服务器,所以还要开启写入操作:

# Uncomment this to enable any form of FTP write command.
write_enable=YES

ftp使用端口21作为控制通道,供用户接入、登录、登出等交换控制信息使用。另外,还需要数据通道,传输上载、下载的数据。在主动模式下,数据通道缺省为端口20,这个我没有改。在被动模式下,需要自行设置一组端口:

# These two options set the ports for passive mode.
pasv_min_port=6789
pasv_max_port=6890

最后,需要在防火墙的设置中开启这些涉及的端口,20、21、6789-6890,这是朋友帮助做的,我也不知道具体如何操作的。

最后,可用浏览器访问ftp服务器,并上传、下载文件,验证以上配置正确。

5.2 配置Travis使用ftp部署

Travis的各个执行环节中,还有一个环节after_success,这是在script命令执行成功之后执行的。部署就是在这个环节进行的,添加如下配置到.travis.yml文件中:

after_success:
    "find ./make/output -type f -exec curl --ftp-create-dirs -u $FTP_USER:$FTP_PASSWORD -T {} ftp://123.45.67.89/myproject/{} \\;"

这个命令由find找出要部署的文件,然后交给curl,上传到服务器上。其中,./make/output为构建的输出目录,123.45.67.89是服务器的IP地址,/myproject/为服务器上要部署的目录。$FTP_USER和$FTP_PASSWORD是Travis持续集成的环境变量,需要在.travis.yml文件中单独设置:

env:
  global:
    - "FTP_USER=myusername"
    - "FTP_PASSWORD=mypassword"

到此,一个基本的包括构建和部署的Travis持续集成环境就算是配置好了。每次这个项目推送到Github库的指定分支,Travis就是自动检测到,自动进行构建,构建成功后就会自动部署到指定的服务器上。

完整的.travis.yml文件如下:

language: python
python:
  - "2.7"

env:
  global:
    - "FTP_USER=myusername"
    - "FTP_PASSWORD=mypassword"

# whitelist
branches:
  only:
    - mybranch

# Use this to prepare the system to install prerequisites or dependencies
before_install: "sudo apt-get update"

# command to install dependencies
install: "pip install -q -r requirements.txt --use-mirrors"

# command to build
script: make html

after_success:
    "find ./make/output -type f -exec curl --ftp-create-dirs -u $FTP_USER:$FTP_PASSWORD -T {} ftp://123.45.67.89/myproject/{} \\;"

6. 结语

本文只是介绍了利用Travis进行持续集成的简单配置,还有一些问题没有说明或解决,比如:

  • ftp不够安全,是否可以使用ftps来加强安全性
  • Travis的配置文件中,ftp的用户名和密码是明文,是可以加密的。

有兴趣的朋友,可以自己研究Travis的文档。

 

附录. 参考资料

  1. Travis CI Documentation
    http://docs.travis-ci.com/
  2. Have Travis-CI test your Sphinx docs
    https://coderwall.com/p/wws2uq/have-travis-ci-test-your-sphinx-docs
  3. how to deploy to own server using ftp
    http://docs.travis-ci.com/user/deployment/custom/
  4. curl: (1) Protocol sftp not supported or disabled in libcurl
    https://github.com/travis-ci/travis-ci/issues/2556
  5. How do I grant sudo privileges to an existing user? [duplicate]
    http://askubuntu.com/questions/168280/how-do-i-grant-sudo-privileges-to-an-existing-user
  6. How can I add a new user as sudoer using the command line?
    http://askubuntu.com/questions/7477/how-can-i-add-a-new-user-as-sudoer-using-the-command-line
  7. Ubuntu 12.04 » Ubuntu Server Guide » File Servers » FTP Server
    https://help.ubuntu.com/12.04/serverguide/ftp-server.html
  8. vsftpd
    https://help.ubuntu.com/community/vsftpd
上一篇: C/C++求职宝典21个重点笔记(常考笔试面试点) 下一篇: 没有下一篇了!
发表评论
用户名: 匿名