Merge pull request #5195 from AlanCoding/job_fail_json

In tower_job_wait intentionally fail module for failure

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-10-31 17:53:53 +00:00
committed by GitHub
2 changed files with 59 additions and 0 deletions

View File

@@ -136,6 +136,12 @@ def main():
json_output['timeout'] = True
except exc.NotFound as excinfo:
fail_json = dict(msg='Unable to wait, no job_id {0} found: {1}'.format(job_id, excinfo), changed=False)
except exc.JobFailure as excinfo:
fail_json = dict(msg='Job with id={} failed, error: {}'.format(job_id, excinfo))
fail_json['success'] = False
result = job.get(job_id)
for k in ('id', 'status', 'elapsed', 'started', 'finished'):
fail_json[k] = result.get(k)
except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
fail_json = dict(msg='Unable to wait for job: {0}'.format(excinfo), changed=False)