tox --parallel--safe-build无法与Jenkins并行管道一起使用

时间:2019-02-13 11:56:03

标签: python jenkins continuous-integration jenkins-pipeline tox

我想在jenkins管道中并行调用python版本2.7和3.6的tox。

问题在于,tox不是线程安全的,但是似乎可以使用选项(--parallel--safe-build)解决,但就我而言不是。似乎没有效果。

可以在本地复制:

  

tox --parallel-safe-build -e py27和tox --parallel-safe-build -e py36   &

将在二分之一中失败。

Jenkinsfile阶段

stage("Compatibility") {
    steps {
        parallel(
            "Python 2.7": {
                sh "venv/bin/tox --parallel--safe-build -e py27"
            },
            "Python 3.6": {
                sh "venv/bin/tox --parallel--safe-build -e py36"
            }
        )
    }
}

tox.ini

[tox]
envlist = py27,py36

[testenv]
deps =
    pytest
commands =
    pytest

Stacktrace

Traceback (most recent call last):
  File "/home/th/.local/lib/python3.7/site-packages/py/_error.py", line 66, in checked_call
    return func(*args, **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '/home/th/dev/commons/.tox/log/tox-0.log'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/th/.local/bin/tox", line 10, in <module>
    sys.exit(cmdline())
  File "/home/th/.local/lib/python3.7/site-packages/tox/session.py", line 47, in cmdline
    main(args)
  File "/home/th/.local/lib/python3.7/site-packages/tox/session.py", line 54, in main
    retcode = build_session(config).runcommand()
  File "/home/th/.local/lib/python3.7/site-packages/tox/session.py", line 467, in runcommand
    return self.subcommand_test()
  File "/home/th/.local/lib/python3.7/site-packages/tox/session.py", line 579, in subcommand_test
    venv.package = self.hook.tox_package(session=self, venv=venv)
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/th/.local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/th/.local/lib/python3.7/site-packages/tox/package/__init__.py", line 13, in tox_package
    session.package, session.dist = get_package(session)
  File "/home/th/.local/lib/python3.7/site-packages/tox/package/__init__.py", line 33, in get_package
    package = acquire_package(config, report, session)
  File "/home/th/.local/lib/python3.7/site-packages/tox/package/__init__.py", line 46, in acquire_package
    path = build_package(config, report, session)
  File "/home/th/.local/lib/python3.7/site-packages/tox/package/builder/__init__.py", line 7, in build_package
    return make_sdist(report, config, session)
  File "/home/th/.local/lib/python3.7/site-packages/tox/package/builder/legacy.py", line 26, in make_sdist
    returnout=True,
  File "/home/th/.local/lib/python3.7/site-packages/tox/session.py", line 255, in popen
    out = outpath.read()
  File "/home/th/.local/lib/python3.7/site-packages/py/_path/common.py", line 170, in read
    with self.open(mode) as f:
  File "/home/th/.local/lib/python3.7/site-packages/py/_path/local.py", line 361, in open
    return py.error.checked_call(open, self.strpath, mode)
  File "/home/th/.local/lib/python3.7/site-packages/py/_error.py", line 86, in checked_call
    raise cls("%s%r" % (func.__name__, args))
py.error.ENOENT: [No such file or directory]: open('/home/th/dev/commons/.tox/log/tox-0.log', 'r')

0 个答案:

没有答案