是否可以允许多个testenv标签使用相同的脚本?

时间:2018-01-17 10:01:20

标签: python jenkins continuous-integration tox

目前,我们有多个toxenv只是一个简单的复制+粘贴代码:

https://github.com/nltk/nltk/blob/alvations-test-tox/tox.ini

[testenv:py2.7.14-jenkins]
basepython = python
commands = {toxinidir}/jenkins.sh
setenv =
    STANFORD_MODELS = {homedir}/third/stanford-parser/
    STANFORD_PARSER = {homedir}/third/stanford-parser/
    STANFORD_POSTAGGER = {homedir}/third/stanford-postagger/


[testenv:py3.5.4-jenkins]
basepython = python3
commands = {toxinidir}/jenkins.sh
setenv =
    STANFORD_MODELS = {homedir}/third/stanford-parser/
    STANFORD_PARSER = {homedir}/third/stanford-parser/
    STANFORD_POSTAGGER = {homedir}/third/stanford-postagger/

[testenv:py3.6.4-jenkins]
basepython = python3
commands = {toxinidir}/jenkins.sh
setenv =
    STANFORD_MODELS = {homedir}/third/stanford-parser/
    STANFORD_PARSER = {homedir}/third/stanford-parser/
    STANFORD_POSTAGGER = {homedir}/third/stanford-postagger/

是否有人为同一个toxenv分配多个标签?

E.g。

[testenv:py3.6.4-jenkins,py3.5.4-jenkins,py3-jenkins]
basepython = python3
commands = {toxinidir}/jenkins.sh
setenv =
    STANFORD_MODELS = {homedir}/third/stanford-parser/
    STANFORD_PARSER = {homedir}/third/stanford-parser/
    STANFORD_POSTAGGER = {homedir}/third/stanford-postagger/

1 个答案:

答案 0 :(得分:1)

不,但您可以通过以下方式重构tox.ini

[testenv]
commands = {toxinidir}/jenkins.sh
setenv =
    STANFORD_MODELS = {homedir}/third/stanford-parser/
    STANFORD_PARSER = {homedir}/third/stanford-parser/
    STANFORD_POSTAGGER = {homedir}/third/stanford-postagger/

[testenv:py2.7.4-jenkins]
basepython = python

[testenv:py3-jenkins]
basepython = python3

[testenv:py3.5.4-jenkins]
basepython = {[testenv:py3-jenkins]basepython}

[testenv:py3.6.4-jenkins]
basepython = {[testenv:py3-jenkins]basepython}

[testenv]定义了所有部分共有的变量。