TeamCity为Python / Django持续集成 [英] TeamCity for Python/Django continuous integration

查看:183
本文介绍了TeamCity为Python / Django持续集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Linux(Ubuntu)框上设置了 TeamCity ,并希望使用它有一些Python / Django项目。



问题是我没有看到下一步该怎么做 - 我试图搜索一个Python特定的构建代理TeamCity但是没有太多的成功。



如何管理?

解决方案

好的,所以有正确的TeamCity集成工作的方法如下:



假设您已经安装了TeamCity,至少有1个构建代理可用



1)配置构建代理执行

  manage.py test 

2)下载并安装此插件,用于TC http://pypi.python.org/pypi/teamcity-messages



3)你会有为您的自定义测试运行器提供插件(2)上班它可以直接拷贝来自django.test.simple的run_tests,只需稍微修改一遍:用TeamcityTestRunner替换测试运行器所在的行,因此设置

  def run_tests(test_labels,verbosity = 1,interactive = True,extra_tests = []):
...
result = unittest.TextTestRunner(verbosity = verbosity).run套件)

使用这个:

  def run_tests(test_labels,verbosity = 1,interactive = True,extra_tests = []):
...
result = TeamcityTestRunner()。run(suite)

您必须将该函数放入解决方案中的文件中,并指定一个托管测试运行器,使用Django的TEST_RUNNER配置属性如下:

  TEST_RUNNER ='my_site.file_name_with_run_tests.run_tests'

确保在 file_name_with_run_tests

$ b $中引用所有必需的导入b

您可以通过运行

  ./ manage.py test 

从命令行,注意输出已更改,现在消息像

  #teamcity .... 

/ p>

I've set up TeamCity on a Linux (Ubuntu) box and would like to use it for some of Python/Django projects.

The problem is that I don't really see what to do next - I tried searching for a Python specific build agent for TeamCity but without much of the success.

How can I manage that?

解决方案

Ok, so there's how to get it working with proper TeamCity integration:

Presuming you have TeamCity installed with at least 1 build agent available

1) Configure your build agent to execute

manage.py test

2) Download and install this plugin for TC http://pypi.python.org/pypi/teamcity-messages

3) You'll have to provide your custom test runner for plugin in (2) to work. It can be straight copy of run_tests from django.test.simple, with only one slight modification: replace line where test runner is called with TeamcityTestRunner, so insted of

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):
    ...
    result = unittest.TextTestRunner(verbosity=verbosity).run(suite)

use this:

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):
    ...
    result = TeamcityTestRunner().run(suite)

You'll have to place that function into a file in your solution, and specify a custome test runner, using Django's TEST_RUNNER configuration property like this:

TEST_RUNNER = 'my_site.file_name_with_run_tests.run_tests'

Make sure you reference all required imports in your file_name_with_run_tests

You can test it by running

./manage.py test

from command line and noticing that output has changed and now messages like

#teamcity....

appearing in it.

这篇关于TeamCity为Python / Django持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆