Record handler tasks in json job output

There's a separate callback method for handler tasks.  This is what
we do in the text stream callback plugin; we should do the same in
the json output.

Change-Id: I48273ec182032f198b8886be95b0cba5c6f4843e
This commit is contained in:
James E. Blair 2019-09-06 08:14:47 -07:00 committed by Clark Boylan
parent 45318b4f19
commit 44b897d74c
3 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,10 @@
- hosts: all
handlers:
- name: handler
shell: echo "This is a handler"
tasks:
- shell: echo "Standard output test {{ zuul.executor.src_root }}"
notify: handler
- shell: echo "This should be skipped"
when: false
- fail:

View File

@ -4926,6 +4926,10 @@ class TestJobOutput(AnsibleZuulTestCase):
['hosts']['localhost']['skipped'])
self.assertTrue(j[0]['plays'][0]['tasks'][2]
['hosts']['localhost']['failed'])
self.assertEqual(
"This is a handler",
j[0]['plays'][0]['tasks'][3]
['hosts']['localhost']['stdout'])
self.log.info(self._get_file(self.history[0],
'work/logs/job-output.txt'))

View File

@ -128,6 +128,9 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_task_start(self, task, is_conditional):
self.results[-1]['tasks'].append(self._new_task(task))
def v2_playbook_on_handler_task_start(self, task):
self.v2_playbook_on_task_start(task, False)
def v2_runner_on_ok(self, result, **kwargs):
host = result._host
action = result._task.action