TeamCity for Python/Django continuous integration

老子叫甜甜 提交于 2019-11-27 09:42:09

问题


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?


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/1091465/teamcity-for-python-django-continuous-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!