TeamCity for Python/Django 持续集成

TeamCity for Python/Django continuous integration(TeamCity for Python/Django 持续集成)

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

问题描述

我在 Linux (Ubuntu) 机器上设置了 TeamCity 并希望使用它适用于一些 Python/Django 项目.

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

问题是我真的不知道下一步该做什么 - 我尝试为 TeamCity 搜索特定于 Python 的构建代理,但没有取得多大成功.

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.

我该如何管理?

推荐答案

好的,下面是如何让它与适当的 TeamCity 集成一起工作:

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

假设您安装了 TeamCity,并且至少有 1 个可用的构建代理

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

1) 配置你的构建代理来执行

1) Configure your build agent to execute

manage.py test

2) 为 TC 下载并安装此插件 http://pypi.python.org/pypi/teamcity-消息

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

3) 您必须为 (2) 中的插件提供自定义测试运行器才能工作.它可以是来自 django.test.simple 的 run_tests 的直接副本,只需稍作修改:将调用测试运行器的行替换为 TeamcityTestRunner,因此插入

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)

使用这个:

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

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

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'

确保在 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....

出现在里面.

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

本文标题为:TeamCity for Python/Django 持续集成

基础教程推荐