Teamcity Python Runner

  1. 6:38youtube.comHow To Install And Run Python Scripts
  2. Github.com › Leo-from-spb › Teamcity-pythonGitHub - Leo-from-spb/teamcity-python: TeamCity Python Runner 2.0
  3. Teamcity Python Build Runner
  4. Teamcity Python Runner Free
  5. 1:32youtube.comRunning A Simple Python Script

For this document, we provide example tests located in our TeamCity plugin GitHub Repository.

As Python becomes the second most popular programming language in the world, you want your continuous integration system to support all of its modern feature. Apr 24, 2013 Experiments performing continuous integration testing in Python with TeamCity. At Bazaarvoice, we use TeamCity for continuous integration testing. This has proved immensely useful for most of our Java projects, however as I am developing a Python application, I wanted to see if I could get TeamCity to run testing on my program. I've authored this plugin in 2011 in spite of the day for running python scripts without problems of locating Python binaries on different platforms. However, that times have changed, and now I don't support this plugin. TeamCity since the version 2020.2 has a new bundled Python Runner that supports also virtual env, test reporting, etc. Dec 16, 2020 TeamCity 2020.2 comes with first-class native Python Support, and you no longer need to use a third-party plugin to build your Python projects. It supports all popular Python build workflows: Run files, modules, or custom scripts. Execute pytests or unittests. Run linters, like flake8 or pylint. Use virtual environments, like virtualenv or pipenv.

TeamCity is a powerful continuous integration tool. In this guide we will use TeamCity along with our TeamCity Plugin for testing using the Selenium WebDriver and the Python programming language.

Set up TeamCity

  1. Visit the TeamCity download page and select the appropriate file version based on your Operating System.

  2. After the TeamCity Application is installed, run the following command from the terminal/command prompt:

    runAll.sh start/runAll.bat start

  3. Navigate to http://localhost:8111 or http://localhost (Windows) and finish set up by creating a user.

Install our TeamCity plugin

  1. Download the CBT TeamCity plugin zip file.

  2. From the Administration page, click the Plugins List link.

  3. Click the Upload plugin zip button.

  4. Add the zip file of the CrossBrowserTesting Plugin. Click Save.

  5. Restart the TeamCity server.

  1. Download CBT TeamCity plugin zip file.

  2. Save the downloaded zip file into your <TeamCity Data Directory>/plugins directory.

  3. Restart the TeamCity server.

Run a test

Note:You will need to use your Username and Authkey to run your tests on CrossBrowserTesting. To get yours, sign up for a free trial or purchase a plan.
  1. Start a new project.

  2. Download and install the Python Runner plugin for TeamCity.

  3. Select Add build step from the Build Steps page.

  4. Select Python from the Runner type list and paste the following python script in the Python script source box:

    Python

    import unittest
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    import requests, time
    import os
    class SeleniumCBT(unittest.TestCase):
    def setUp(self):
    self.username = os.environ.get('CBT_USERNAME')
    self.authkey = os.environ.get('CBT_APIKEY')
    self.api_session = requests.Session()
    self.api_session.auth = (self.username,self.authkey)
    self.test_result = None
    caps = {}
    caps['name'] = os.environ.get('CBT_BUILD_NAME')
    caps['os_api_name'] = os.environ.get('CBT_OPERATING_SYSTEM')
    caps['browser_api_name'] =os.environ.get('CBT_BROWSER')
    caps['screen_resolution'] = os.environ.get('CBT_RESOLUTION')
    caps['record_video'] = 'true'
    try:
    self.driver = webdriver.Remote(
    desired_capabilities=caps,
    command_executor='http://%s:%s@hub.crossbrowsertesting.com:80/wd/hub'%(self.username, self.authkey))
    except Exception as e:
    raise e
    def test_CBT(self):
    try:
    self.driver.get('http://crossbrowsertesting.github.io/selenium_example_page.html')
    time.sleep(10)
    self.assertEqual(self.driver.title, 'Selenium Test Example Page')
    self.test_result = 'pass'
    except AssertionError as e:
    self.drvier.quit()
    # log the error message, and set the score
    self.api_session.put('https://crossbrowsertesting.com/api/v3/selenium/' + self.driver.session_id + '/snapshots/' + snapshot_hash,
    data={'description':'AssertionError: ' + str(e)})
    self.test_result = 'fail'
    raise
    self.driver.quit()
    # Here we make the api call to set the test's score
    # Pass if it passes, fail if an assertion fails, unset if the test didn't finish
    ifself.test_result isnot None:
    self.api_session.put('https://crossbrowsertesting.com/api/v3/selenium/' + self.driver.session_id,
    data={'action':'set_score', 'score':self.test_result})
    if __name__ '__main__':
    unittest.main()

  5. Select Add build feature from the Build Features page.

  6. Select CrossBrowserTesting from the Build feature list and configure.

  7. Click the Run button and view your results.

Environment variables

The CrossBrowserTesting TeamCity Plugin passes your build step information to your Selenium scripts as environment variables. The exact syntax will vary depending on your scripting language.

VariableDescription
CBT_USERNAMEThe username used on CrossBrowserTesting for Selenium Testing.
CBT_APIKEYThe API key used on CrossBrowserTesting for Selenium Testing.
CBT_BUILD_NAMEThe TeamCity Project's name.
CBT_BUILD_NUMBERThe TeamCity Project’s current build number.
CBT_OPERATING_SYSTEMThe apiname of the selected Operating System.
CBT_BROWSERThe apiname of the selected Browser.
CBT_BROWSERSAn array of JSON objects containing the 'operating_system', 'browser', 'resolution', and 'browserName' of each configuration specified.
CBT_RESOLUTIONThe name of the selected Screen Resolution.

Use a local connection

If you would like to test behind your firewall or access non-public sites, you can use our local connection tool directly through our TeamCity plugin. Simply check Use Local Tunnel check box. (The CrossBrowserTesting Node.js Tunnel must be installed globally).

Conclusions

By following the steps outlined in this guide, you are now able to seamlessly integrate TeamCity and CrossBrowserTesting. If you have any questions or concerns, please feel free to reach out to our support team.

See Also

Latest version

Released:

Send test results to TeamCity continuous integration server from unittest, nose, py.test, twisted trial, behave (Python 2.6+)

Project description

This package integrates Python with theTeamCity Continuous Integration(CI) server. It allows sending “servicemessages”from Python code. Additionally, it provides integration with thefollowing testing frameworks and tools:

Usage

This package uses service messages to report the build status to TeamCity.See https://confluence.jetbrains.com/display/TCDL/Build+Script+Interaction+with+TeamCityfor more details

unittest

If you wish to use the Python default unittest framework, you shouldmodify the Test runner, e.g.:

See examples/simple.py for a full example.

If you are used to running unittest from the command line, instead ofusing python -m unittest, you could usepython -m teamcity.unittestpy.

nose

Test status reporting is enabled automatically under TeamCity build.

py.test

Test status reporting is enabled automatically under TeamCity build.

Django

For Django 1.6+: Use the TeamcityDjangoRunner runner instead of thedefault DiscoverRunner by changing the following setting in yoursettings.py:

If you are using another test runner, you should override therun_suite method or use the DiscoverRunner.test_runner propertyintroduced in Django 1.7.

flake8

Test status reporting is enabled automatically under TeamCity build.

PyLint

Add --output-format=teamcity.pylint_reporter.TeamCityReporter tothe pylint command line.

tox

Pass TEAMCITY_VERSION environment variable inside your test virtenv.TEAMCITY_VERSION environment variable exists during build on TeamCity.teamcity-messages uses it in order to enable reporting to TeamCity.

Twisted trial

Add --reporter=teamcity option to trial command line

Python version compatibility

See https://pypi.org/project/teamcity-messages for Python version compatibility

Contact information

TeamCity support: http://www.jetbrains.com/support/teamcity

License

Apache, version 2.0 http://www.apache.org/licenses/LICENSE-2.0

Change Log

Version 1.29 Fri Jun 25 2021
  • python: supported Python 3.9
  • support pylint >= 2.8 by @Tirzono #242
  • pytest: add an option to swap actual/expected in diff
Version 1.28 Thu Apr 30 2020
  • support coverage >= 5.0.1 by @enkelli #225 #218
  • python: dropped Python 2.6, 3.5 support. Latest version to support them is 1.27
  • python: supported Python 3.8
Version 1.27 Fri Nov 8 2019
  • pylint: more compatibility fixes #215
Version 1.26 Tue Nov 5 2019
  • drop Python 3.4 support
  • pylint: support pylint >= 2.3 by @PetrWolf #215
  • unittest: fix test hierarchy for subtests in tests with doc comments by @throwable-one #221
Version 1.25 Mon Apr 15 2019
  • pytest: fix comparing asserts by @ikonst #210
  • Retry writes to stream on a EAGAIN IOError by @morganwahl #213
Version 1.24 Mon Mar 18 2019
  • pylint: initial support by @PetrWolf #171 #200
Version 1.23 Sun Mar 10 2019
  • Correct supported python versions, description, keywords

Version 1.22 Sun Mar 10 2019

  • python: dropped Python 2.4, 2.5, 3.2, 3.3 support. Latest version to support them is 1.21
  • python: supported Python 3.6, 3.7
  • behave: initial support
  • unittest: subtests support
  • various unicode fixes
  • nose, unittest: correctly capture stdout to provide better test output
  • twisted: format twisted Failure objects by @jackrobison
  • various test infrastructure fixes by @sambrightman
  • flake8: correctly initialize options by @sambrightman
  • various fixes to use teamcity-messages code in JetBrains PyCharm IDE

Version 1.21 Mon Jan 2 2017

  • pytest: internal Error during test collection with pytest and teamcity-messages plugin #112
  • nose: support capturing test output from successful tests, #113
  • Fix possible error when joining bytes and unicode (Victor Makarov, https://github.com/vitek)

Version 1.20 Wed Aug 3 2016

  • flake8: 3.x support (Marc Abramowitz, https://github.com/msabramo)
  • flake8: –no-teamcity option for 3.x

Version 1.19 Sun Jun 26 2016

Python Runner - Plugins | JetBrains
  • fix flake8 2.6.0 support #103 (Cody Maloney, https://github.com/cmaloney)

Version 1.18 Fri May 27 2016

  • pytest: do not report setup fixtures as separate tests (https://github.com/JetBrains/teamcity-messages/issues/91)
  • pytest: better test location presentation
  • pytest: support for pytest-pep8 and pytest-lint plugins
  • nose: make sure to turn reason into string when skipping test #98 (Piyush Gupta, https://github.com/piyushg91)
  • twisted: fix twisted failure test reporting #88 (Alexey Larkov, https://github.com/gmlexx)
  • flake8: better test name #89 (Marc Abramowitz, https://github.com/msabramo)
  • Don’t force a newline at the start of service messages #90 (Gary Donovan, https://github.com/garyd203)

Version 1.17 Sat Oct 17 2015

  • support coverage >= 4.0
  • automatically detect TeamCity in flake8 plugin (Marc Abramowitz, https://github.com/msabramo)
  • more messages support (Marc Abramowitz, https://github.com/msabramo)buildProblem, buildStatus, setParameter, importData, enableServiceMessages, disableServiceMessages etc

Version 1.16 Sat Sep 12 2015

Runner
  • blocks messages support (Marc Abramowitz, https://github.com/msabramo)

Version 1.15 Fri Aug 28 2015

  • Twisted’s trial support (Alexey Larkov, https://github.com/gmlexx)
  • nose: fix tests reporting in multiprocess environment, thanks to Lewis Coates, https://github.com/lewisc
  • Fix UnicodeEncodeError when sys.stdout.encoding is None, thanks to Marc Abramowitz, https://github.com/msabramo

Version 1.14 Sat May 23 2015

6:38youtube.comHow To Install And Run Python Scripts

  • support python 2.4, 2.5
  • nose: report skip test reason (Lewis Coates, https://github.com/lewisc)

Version 1.13 Sun Mar 29 2015

  • report coverage statistics from py.test pytest-cov plugin (Joseph Lombrozo, https://github.com/djeebus)
  • flake8 support (Joseph Lombrozo, https://github.com/djeebus)

Version 1.12 Fri Jan 16 2015

  • unittest: fix 2.6 compat

Version 1.11 Fri Jan 16 2015

  • nose: handle errors/failures in teardown/setup
  • nose: support multiprocess mode
  • nose: correctly report captured output
  • unittest: support skipped tests in Python 2.6 (by unittest2)
  • unittest: support subtests (Python 3.4+)

Version 1.10 Fri Jan 09 2015

  • py.test: limit captured stdout/stderr by 1M per test and send it to TeamCity in chunks of 50K chars
  • py.test: automatically enable TeamCity reporting under TeamCity build
  • py.test: analyze capture flag of capture plugin and set captureStandardOutput parameter of testStarted accordingly
  • py.test: report setup failures as a separate test
  • py.test: report captured stdout/stderr (Aron Curzon, https://github.com/curzona) https://github.com/JetBrains/teamcity-messages/issues/12
  • py.test: fix parallel tests reporting https://github.com/JetBrains/teamcity-messages/issues/11

Version 1.9 Thu Jan 08 2015

  • Django support (Ralph Broenink, https://github.com/ralphje)
  • Fix test hierarchies on nose and py.test
  • py.test: report errors in setup and teardown
  • py.test: report collect errors
  • py.test: support xfail
  • nose: support skipped tests
  • unittest: support skip, expected failure and unexpected success
  • Totally rewritten integration tests* Thanks to Ralph Broenink (https://github.com/ralphje) and Leonid Bushuev (https://github.com/leo-from-spb)

Version 1.8 Sat Feb 08 2014

  • extensive tests for nose integration (James Carpenter)
  • added timestamps to TeamCity service messages (James Carpenter)
Teamcity Python Runner

Version 1.7 Sun Feb 03 2013

  • py.test support (Aaron Buchanan)
  • official Python 3 support

Version 1.6 Tue Dec 06 2011

  • Bundle forgotten examples/simple.py

Version 1.4 Tue Apr 27 2010

  • Fixed http://youtrack.jetbrains.net/issue/TW-11313

Version 1.3 Fri Apr 11 2008

  • Added newlines due to http://youtrack.jetbrains.net/issue/TW-4412

Version 1.2 Thu Apr 10 2008

  • Fixed tests gold data

Version 1.1 Thu Apr 10 2008

  • Fixed README

Version 1.0 Tue Apr 08 2008

  • initial release

Release historyRelease notifications | RSS feed

1.29

1.28

1.27

1.26

1.25

1.24

1.23

1.21

1.20

1.19

1.18

Github.com › Leo-from-spb › Teamcity-pythonGitHub - Leo-from-spb/teamcity-python: TeamCity Python Runner 2.0

1.17

1.16

1.15

1.14

1.13

1.12

1.11

1.10

1.9

1.8

1.7

1.6

1.5

1.4

1.3

1.2

1.1

Teamcity Python Build Runner

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Teamcity Python Runner Free

Files for teamcity-messages, version 1.29
Filename, sizeFile typePython versionUpload dateHashes
Filename, size teamcity_messages-1.29-py3-none-any.whl (32.9 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size teamcity-messages-1.29.tar.gz (33.4 kB) File type Source Python version None Upload dateHashes
Close

Hashes for teamcity_messages-1.29-py3-none-any.whl

Hashes for teamcity_messages-1.29-py3-none-any.whl
AlgorithmHash digest
SHA2565732a3c64d1961c321751c397e5225f8fbc4dd4af1a94ab235d8aba0a4e2ba05
MD554aaacc1160d1a0255775a895ff1d838
BLAKE2-25693d623e71df7c92a5c5b26075ef1af2a34c13746cf7fcd2325afc18ab48887c6
Close

Hashes for teamcity-messages-1.29.tar.gz

1:32youtube.comRunning A Simple Python Script

Hashes for teamcity-messages-1.29.tar.gz
AlgorithmHash digest
SHA256d12329b8e1c8e125527929b5e639a2ca01e043e26167f367088af96d0fc6aba4
MD5957f47b539b8d50ec8947ed04e5a7739
BLAKE2-2567bd5ac6c09ed747b377eb6c513153467d3a91a531f9cd9736feb6d46a09ab07f