tox-jenkins-override

tox-jenkins-override

A tox v4 plugin to restore support for overriding tox settings while running under Jenkins (as defined by JENKINS_URL environment variable being defined). It overrides settings from [tox] section with the settings from the [tox:jenkins].

Example:

The use case is for local use to rely on whatever python 3 version is available, but on CI run tests against a fixed set of python versions (which might not be available locally or differ from the local environment).

One would thus define a py3-test for local use and when running under Jenkins set more specific environments for each of Python 3.9, 3.10 and 3.11.

Since we want to ensure CI tests against each request python version, we want to ensure tox will not skip running a testenv when the CI environment lacks a requested python. To do so we set skip_missing_interpreters to False. In tox.ini:

[tox]
envlist = py3-test

[tox:jenkins]
envlist = py{39,310,311}-test
skip_missing_interpreters = False

When showing the core configuration:

$ tox config --core -k skip_missing_interpreters
[testenv:py3-test]
[tox]
skip_missing_interpreters = True
$

When setting the JENKINS_URL environment variable the plugin injects the config:

$ JENKINS_URL=1 tox config --core -k skip_missing_interpreters
ROOT: tox-jenkins> Inserting [tox:jenkins] configuration
[testenv:py39-test]
[testenv:py310-test]
[testenv:pypy-test]
[tox]
skip_missing_interpreters = False
$

The plugin is discovered by tox via an entry-point, thus to enable the plugin you must install it in the environment tox is running in.

pip install --user \
    git+https://gerrit.wikimedia.org/r/integration/tox-jenkins-override.git#egg=tox-jenkins-override

Online documentation

This documentation online: https://doc.wikimedia.org/tox-jenkins-override/