Python/Django的TeamCity持续集成

时间:2021-10-22 21:22:37

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

我已经在Linux (Ubuntu)框上建立了TeamCity,并希望将它用于Python/Django项目中的一些项目。

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搜索Python特定的构建代理,但没有取得多大成功。

How can I manage that?

我该怎么做呢?

2 个解决方案

#1


21  

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

好的,那么如何使它与适当的TeamCity集成一起工作:

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

假设您已经安装了至少一个构建代理的TeamCity

1) Configure your build agent to execute

1)配置构建代理以执行

manage.py test

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

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

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

3)您必须为插件(2)提供自定义测试运行器才能工作。它可以是django.test的run_tests的直接拷贝。简单,只有一个小小的修改:替换线,测试跑者被称为TeamcityTestRunner,所以insted。

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:

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

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

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

出现在它。

#2


2  

I have added feature request to TeamCity issue tracker, to make full-featured python support. This is the link: http://youtrack.jetbrains.com/issue/TW-25141. If you interested, you can vote for it, and that may force JetBrains to improve python support.

我已经向TeamCity问题跟踪器添加了特性请求,以提供功能全面的python支持。这是链接:http://youtrack.jetbrains.com/issues e/tw-25141。如果您感兴趣,可以投票支持它,这可能会迫使JetBrains改进python支持。

#1


21  

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

好的,那么如何使它与适当的TeamCity集成一起工作:

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

假设您已经安装了至少一个构建代理的TeamCity

1) Configure your build agent to execute

1)配置构建代理以执行

manage.py test

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

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

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

3)您必须为插件(2)提供自定义测试运行器才能工作。它可以是django.test的run_tests的直接拷贝。简单,只有一个小小的修改:替换线,测试跑者被称为TeamcityTestRunner,所以insted。

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:

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

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

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

出现在它。

#2


2  

I have added feature request to TeamCity issue tracker, to make full-featured python support. This is the link: http://youtrack.jetbrains.com/issue/TW-25141. If you interested, you can vote for it, and that may force JetBrains to improve python support.

我已经向TeamCity问题跟踪器添加了特性请求,以提供功能全面的python支持。这是链接:http://youtrack.jetbrains.com/issues e/tw-25141。如果您感兴趣,可以投票支持它,这可能会迫使JetBrains改进python支持。