0

I have configured email notification on my jenkins build which triggers email post every build to recipients with the console output content as the email content. Currently it looks something like this:

See <http://localhost:8080/job/B2B%20Tavern%20Tests/99/display/redirect>

------------------------------------------
Started by user admin
Building in workspace <http://localhost:8080/job/B2B%20Tavern%20Tests/ws/>
[B2B Tavern Tests] $ /bin/bash /tmp/jenkins9005872573019149559.sh
hello.py
Tasks
test_server.tavern.yaml
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.6.1, py-1.5.3, pluggy-0.6.0 -- /home/delhivery/.env/env/bin/python2
cachedir: .pytest_cache
rootdir: /home/delhivery/Documents, inifile:
plugins: tavern-0.10.2
collecting ... collected 10 items

test_server.tavern.yaml::Extract data from the lrn  api PASSED           [ 10%]
test_server.tavern.yaml::Create No Data with expired Authorization PASSED [ 20%]
test_server.tavern.yaml::Create No Data with valid data and check upload status PASSED [ 30%]
test_server.tavern.yaml::Validate cases of LRN Availability with valid data FAILED [ 40%]
test_server.tavern.yaml::Independent cases for basic manifest api FAILED [ 50%]
test_server.tavern.yaml::Validate No Data upload status with invalid or non-existant jobid PASSED [ 60%]
test_server.tavern.yaml::Combo API with valid data and storeId PASSED    [ 70%]
test_server.tavern.yaml::Combo API with valid data new Address and with client token PASSED [ 80%]
test_server.tavern.yaml::Create No Data with valid data and validate patch api with valid data PASSED [ 90%]
test_server.tavern.yaml::Tests for Ewaybill validation apis FAILED       [100%]Traceback (most recent call last):
  File "/home/delhivery/.env/env/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/_pytest/config.py", line 63, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
    return outcome.get_result()
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
    _reraise(*ex)  # noqa
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/_pytest/main.py", line 208, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/_pytest/main.py", line 201, in wrap_session
    session=session, exitstatus=session.exitstatus
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 196, in _multicall
    gen.send(outcome)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/_pytest/terminal.py", line 579, in pytest_sessionfinish
    outcome.get_result()
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
    _reraise(*ex)  # noqa
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/home/delhivery/.env/env/local/lib/python2.7/site-packages/_pytest/junitxml.py", line 524, in pytest_sessionfinish
    logfile = open(self.logfile, "w", encoding="utf-8")
  File "/home/delhivery/.env/env/lib/python2.7/codecs.py", line 896, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 13] Permission denied: '/home/delhivery/Documents/pytest_tests.xml'
Build step 'Execute shell' marked build as failure

I want the email content to start from where it says 'test session starts' and end at '[100%]'

How can I do that any suggestions?

  • Using the Email-ext plugin along with BUILD_LOG_REGEX to specify a regex pattern and the preceding/following n lines to customize the output content. See stackoverflow.com/questions/9439450/… – Sathyajith Bhat Dec 9 '18 at 12:09
  • How are you sending the e-mail? Are you using an e-mail step in a Jenkinsfile or Pipeline script? If so, what step? Are you using a plugin? If so, what plugin? – jayhendren Dec 10 '18 at 17:10
  • Using Email Extension Plugin. Also what I intend to send is mentioned in the aforementioned question, Thanks! – Rohan Kalia Dec 10 '18 at 18:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.