From 542f9489527a7c0523b0e541d674e4c5cab756ee Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 11 Jul 2017 10:02:57 +0200 Subject: [PATCH] Check ret for None in zuul_run_command The check 'if not ret' not only matches a missing return code but also the value 0 which is actually a successful run. Thus successful commands end with an error 'Something went horribly wrong during task execution'. This can be fixed by explicitly checking for None. Also adds a successful shell task to the test_playbook test case which fails without this patch. Change-Id: If1d0721574a82e247659ab0f865ae6acfe12a6be --- .../ansible/git/common-config/playbooks/hello-post.yaml | 4 ++++ zuul/ansible/library/command.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/hello-post.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/hello-post.yaml index d528be1d4e..36a22e415d 100644 --- a/tests/fixtures/config/ansible/git/common-config/playbooks/hello-post.yaml +++ b/tests/fixtures/config/ansible/git/common-config/playbooks/hello-post.yaml @@ -10,3 +10,7 @@ that: - st.stat.exists - st.stat.isreg + + - name: Simple shell task. + shell: |+ + echo "Hello world" diff --git a/zuul/ansible/library/command.py b/zuul/ansible/library/command.py index d27c83ea24..f701b489c6 100644 --- a/zuul/ansible/library/command.py +++ b/zuul/ansible/library/command.py @@ -409,9 +409,9 @@ def zuul_run_command(self, args, zuul_log_id, check_rc=False, close_fds=True, ex if t.isAlive(): console.addLine("[Zuul] standard output/error still open " "after child exited") - if not ret and fail_json_kwargs: + if ret is None and fail_json_kwargs: ret = fail_json_kwargs['rc'] - elif not ret and not fail_json_kwargs: + elif ret is None and not fail_json_kwargs: ret = -1 console.addLine("[Zuul] Task exit code: %s\n" % ret) if ret == -1 and not fail_json_kwargs: