Удаленка для jenkins+selenide+selenoid+allure+docker спецов на 2-3 часа в день. 100% remote! Присоединиться к проекту

Как правильно запускать python тесты Allure + PyTest + Jenkins !

jenkins
allure
python
Теги: #<Tag:0x00007fedc1a95c70> #<Tag:0x00007fedc1a95518> #<Tag:0x00007fedc1a94be0>

(Вадим) #1

Локально запускаю тесты с использованием virtualenv. При локальном запуске все проходит и формируется отчет по командам :
source my_project/bin/activate
py.test case.py --alluredir=reporthttp://automated-testing.info/
allure serve report
А вот если данные команды прописываю в Jenkins:
а) Получаю такой лог
** > /usr/bin/git config core.sparsecheckout # timeout=10**
** > /usr/bin/git checkout -f 5f0fa9432fdb2a815976118019633fc3d71c8f47**
** > /usr/bin/git rev-list 5f0fa9432fdb2a815976118019633fc3d71c8f47 # timeout=10**
[Allure_test] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson930762478837889033.sh
+ source my_project/bin/activate
++ deactivate nondestructive
++ unset -f pydoc
++ ‘[’ -z ‘’ ']'
++ ‘[’ -z ‘’ ']'
++ ‘[’ -n /bin/sh ']'
++ hash -r
++ ‘[’ -z ‘’ ']'
++ unset VIRTUAL_ENV
++ ‘[’ ‘!’ nondestructive = nondestructive ']'
++ VIRTUAL_ENV=/Users/user/Desktop/autotesting2/my_project
++ export VIRTUAL_ENV
++ _OLD_VIRTUAL_PATH=/usr/bin:/bin:/usr/sbin:/sbin
++ PATH=/Users/user/Desktop/autotesting2/my_project/bin:/usr/bin:/bin:/usr/sbin:/sbin
++ export PATH
++ ‘[’ -z ‘’ ']'
++ ‘[’ -z ‘’ ']'
++ _OLD_VIRTUAL_PS1=
++ ‘[’ x ‘!=’ x ']'
+++ basename /Users/user/Desktop/autotesting2/my_project
++ PS1=’(my_project) '
++ export PS1
++ alias pydoc
++ ‘[’ -n /bin/sh ']'
++ hash -r
+ py.test case.py --alluredir=report
/Users/Shared/Jenkins/tmp/hudson930762478837889033.sh: line 3: py.test: command not found
Build step ‘Execute shell’ marked build as failure
[Allure_test] $ /Users/Shared/Jenkins/Home/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure2/bin/allure generate -o /Users/Shared/Jenkins/Home/workspace/Allure_test/allure-report
Report successfully generated to /Users/Shared/Jenkins/Home/workspace/Allure_test/allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Publishing Selenium report…

б) Если меняю строку запуска на python2.7 -m pytest case.py --alluredir=report получаю такой лог:

> /usr/bin/git config core.sparsecheckout # timeout=10
** > /usr/bin/git checkout -f 5f0fa9432fdb2a815976118019633fc3d71c8f47**
** > /usr/bin/git rev-list 5f0fa9432fdb2a815976118019633fc3d71c8f47 # timeout=10**
[Allure_test] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson6291868144203740517.sh
+ source my_project/bin/activate
++ deactivate nondestructive
++ unset -f pydoc
++ ‘[’ -z ‘’ ']'
++ ‘[’ -z ‘’ ']'
++ ‘[’ -n /bin/sh ']'
++ hash -r
++ ‘[’ -z ‘’ ']'
++ unset VIRTUAL_ENV
++ ‘[’ ‘!’ nondestructive = nondestructive ']'
++ VIRTUAL_ENV=/Users/user/Desktop/autotesting2/my_project
++ export VIRTUAL_ENV
++ _OLD_VIRTUAL_PATH=/usr/bin:/bin:/usr/sbin:/sbin
++ PATH=/Users/user/Desktop/autotesting2/my_project/bin:/usr/bin:/bin:/usr/sbin:/sbin
++ export PATH
++ ‘[’ -z ‘’ ']'
++ ‘[’ -z ‘’ ']'
++ _OLD_VIRTUAL_PS1=
++ ‘[’ x ‘!=’ x ']'
+++ basename /Users/user/Desktop/autotesting2/my_project
++ PS1=’(my_project) '
++ export PS1
++ alias pydoc
++ ‘[’ -n /bin/sh ']'
++ hash -r
+ python2.7 -m pytest case.py --alluredir=report
Traceback (most recent call last):
** File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 162, in _run_module_as_main**
** “main”, fname, loader, pkg_name)**
** File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 72, in _run_code**
** exec code in run_globals**
** File “/Library/Python/2.7/site-packages/pytest.py”, line 73, in **
** raise SystemExit(pytest.main())**
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 49, in main**
** config = _prepareconfig(args, plugins)**
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 158, in _prepareconfig**
** pluginmanager=pluginmanager, args=args)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 745, in call**
** return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 339, in _hookexec**
** return self._inner_hookexec(hook, methods, kwargs)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 334, in **
** _MultiCall(methods, kwargs, hook.spec_opts).execute()**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 613, in execute**
** return _wrapped_call(hook_impl.function(args), self.execute)*
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 250, in _wrapped_call**
** wrap_controller.send(call_outcome)**
** File “/Library/Python/2.7/site-packages/_pytest/helpconfig.py”, line 34, in pytest_cmdline_parse**
** config = outcome.get_result()**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 280, in get_result**
** _reraise(ex) # noqa*
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 265, in init**
** self.result = func()**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 614, in execute**
** res = hook_impl.function(args)*
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 928, in pytest_cmdline_parse**
** self.parse(args)**
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 1100, in parse**
** self._preparse(args, addopts=addopts)**
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 1062, in _preparse**
** self.pluginmanager.load_setuptools_entrypoints(‘pytest11’)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 516, in load_setuptools_entrypoints**
** self.register(plugin, name=ep.name)**
** File “/Library/Python/2.7/site-packages/_pytest/config.py”, line 252, in register**
** ret = super(PytestPluginManager, self).register(plugin, name)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 371, in register**
** hook._maybe_apply_history(hookimpl)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 768, in _maybe_apply_history**
** res = self._hookexec(self, [method], kwargs)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 339, in _hookexec**
** return self._inner_hookexec(hook, methods, kwargs)**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 334, in **
** _MultiCall(methods, kwargs, hook.spec_opts).execute()**
** File “/Library/Python/2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 614, in execute**
** res = hook_impl.function(args)*
** File “/Library/Python/2.7/site-packages/allure_pytest/plugin.py”, line 33, in pytest_addoption**
** severities = [x.value for x in list(allure.severity_level)]**
AttributeError: ‘module’ object has no attribute 'severity_level’
Build step ‘Execute shell’ marked build as failure
[Allure_test] $ /Users/Shared/Jenkins/Home/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure2/bin/allure generate -o /Users/Shared/Jenkins/Home/workspace/Allure_test/allure-report
Report successfully generated to /Users/Shared/Jenkins/Home/workspace/Allure_test/allure-report
Allure report was successfully generated.
Creating artifact for the build.

Подскажите, в чем проблема ?


(rmerkushin) #2

Что-то очень жуткое :slight_smile: Не пробовали использовать pyenv?

мы как-то так запускаем, правда Behave:

source ~/.bashrc
pyenv activate scrm-tests
behave --junit --junit-directory ./reports ./features/${feature}

На крайняк завернитесь в докер )))