Python-Django 使用 Hudson做CI服务器实践记

原创 2012年03月31日 14:34:50

Python-Django 使用 Hudson做CI服务器实践记


作者:Wally Yu

CSDN:http://blog.csdn.net/quicktest

微博:http://www.weibo.com/quicktest

我的环境:

开发环境: Windows XP

运行环境:Ubuntu 11

Python:2.7

Django:1.3.1


国内没有找到比较好的翻译和实践性的博文,于是去了Google,按照一篇文章的做法一步步实现,实践到“Displaying unit test results”的时候因为原文使用了自己的bash,而我需要使用Django自带的unit test的框架,于是修改这一段


原文:

Displaying unit test results

What this isn’t doing it making some pretty graphs and charts. Let’s see about getting some of that enabled.

Pygments uses Nose tests for it’s unit tests. That’s pretty nice, because Nose includes a mechanism to output the format of the tests into Java-based JUnit format, and Hudson in turn knows how to make pretty pictures from that format. Since we installed the nose library earlier, we can take advantage of it. Probably the “right” way to do this would be to change the Makefile to invoke the tests that output XML for the unit tests. For right now, we’ll just shim it into place with new build steps.

  • Change the content of the Execute shell build step and replace it with
    python tests/run.py --with-xunit
  • save the configuration and invoke “Build Now”
  • now look in the workspace in you should find a new file called “nosetests.xml” in the tests subdirectory.

Let’s get that graphed…

  • Go to the job configuration and enable “Publish JUnit test result report”. It will have a text field so that you can tell it where to find the results. It uses an Ant format for finding filenames in an existing directory structure.
  • In this case use **/tests/nosetests.xml
  • Save the config
  • invoke Build Now

现在我的做法:

使用unittest-xml-reporting,官网:https://github.com/danielfm/unittest-xml-reporting#readme

具体做法:

1)shell输入安装unittest-xml-reporting:

pip install unittest-xml-reporting

2)在Django项目的Settings.py输入:

TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
TEST_OUTPUT_VERBOSE = True
TEST_OUTPUT_DESCRIPTIONS = True
TEST_OUTPUT_DIR = 'unitTestResults'

3)回到shell,执行:
python manage.py test

4)执行完后会发现多出一个名为"unitTestResults”的文件夹,点进去看一下,发现里头有很多xml的文件生成

5)进入hudson的项目管理“configure”

http://Your IP Addr:8080/job/Your Project/configure

6)钩上“Publish Junit test result report”

7)地址填上“*/unitTestResults/*.xml”

8)保存

9)做个新Build,点 Build Now

10)Build完后会发现多出一个“Latest Test Results”的链接。点进去可以查看详细信息

11)同时会发现右边多出一个名为“Test Result Trend”的图

后面的就和原文一样了

Now you’ll see a new element in the web user interface called “Latest Test Result” which you can dig into. If you invoke “Build Now” again, it will start graphing the results of the tests and making that trend available in the project view. Right now this graph is going to be really darned boring, because there aren’t any changes between builds. Once more code starts rolling in, you’ll see changes with the number of tests being invoked. You can also click on that link and see the tests that were invoked. For python folks, remember that we’re shimming Python unit tests into a JUnit conceptual framework, so there are going to be some “leaky abstractions here”. In particular, test names, classes, and such may not alway match up with expectations. I have more details on how to enable XML output for a Django based test runner that I’ll post in another write up… uh, later.

hudson12

按照原文的做法,我也顺利的生成了Code Coverage和Pylint

这里要感谢原作者Joe Heck


附上原文的链接:

http://www.rhonabwy.com/wp/2009/11/04/setting-up-a-python-ci-server-with-hudson/



相关文章推荐

Python Web项目中使用Jenkins进行持续集成CI

在Python Web项目中使用Jenkins进行持续集成∞ 转载原文:http://www.hustlzp.com/post/2014/08/jenkins 在一个项...

持续集成--Hudson CI服务器搭建

开始先说段废话激励一下自己,又有好几天没有写博客了!!希望自己可以坚持下去保持持续学习积累知识的热情。 搭建环境: 环境: CentOS 6.6、 JDK7、Tomcat7、 Hudson-3.2....

Git、Gerrit与Jenkins/Hudson CI服务器

Git、Gerrit与Jenkins/Hudson CI服务器 作者Alex Blewitt译者丁雪丰发布于2011年9月6日 领域语言 & 开发,过程 & 实践主题Java , 团队协作 , ...

Linux环境下的持续集成之Hudson CI服务器的安装与配置

一、安装 1、下载 hudson-1.396.war   路径:http://hudson-ci.org/,过程不表 2、把hudson-1.396.war复制到tomcat安装路径的web...

Python+Django+Ubuntu+Apache+Nginx架设服务器成功记

是看一个国外网站一步一步照着来的,复制过来 http://www.ventanazul.com/webzine/tutorials/django-deployment-guide-ubuntu ...

Hudson 持续集成服务器的安装配置与使用

Hudson 持续集成服务器的安装配置与使用

Dubbo实战教程--Hudson持续集成服务器的安装配置与使用

IP:192.168.4.221  8G内存(Hudson多个工程在同时构建的情况下比较耗内存) 环境:CentOS 6.6、JDK7 Hudson不需要用到数据库   Hudson只是一个持...
  • whs_321
  • whs_321
  • 2016年06月05日 14:24
  • 1154

持续集成篇_08_Hudson持续集成服务器的使用(自动化编译、分析、打包、部署)

Hudson持续集成服务器的使用(自动化编译、分析、打包、部署)

持续集成(CI)工具------Hudson/Jenkins(Continuous Integration)安装与配置详解

本文允许转载,但请标明出处:http://blog.csdn.net/wanghantong/article/40985653/, 版权所有 文章概述: 一、 描述了持续集成工具Hud...
  • xwq911
  • xwq911
  • 2015年10月10日 10:54
  • 362
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Python-Django 使用 Hudson做CI服务器实践记
举报原因:
原因补充:

(最多只允许输入30个字)