Skip to content

Commit b36d4b5

Browse files
author
droberts2013
committed
Omit empty body elements, fail task on failed job
1 parent e494501 commit b36d4b5

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
defaultTasks 'build'
1313
apply plugin: 'java'
1414

15-
version='1.1.7'
15+
version='1.1.8'
1616
sourceSets.main.resources.srcDirs = ["src"]
1717

1818
license {

src/ansibletower/launchAndWait.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828

2929
def create_payload(extra_vars, jobTags, credentials):
3030
body = {}
31-
body['extra_vars'] = extra_vars
32-
body['job_tags'] = ",".join(jobTags)
33-
body['credentials'] = credentials
31+
if extra_vars:
32+
body['extra_vars'] = extra_vars
33+
if jobTags:
34+
body['job_tags'] = ",".join(jobTags)
35+
if credentials:
36+
body['credentials'] = credentials
3437
body_as_string = json.dumps(body)
3538
print "Body returned from create_payload() is %s" % body_as_string
3639
return body_as_string

src/ansibletower/launchAndWait.wait_for_completion.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def formatted_print(message):
5151
result = json.loads(response.response)
5252
status=result['status']
5353
task.setStatusLine("Job id %s %s" % (job_id, status))
54-
formatted_print(">>> Task status after " + str(num_tries) + " tries is "+ status)
54+
formatted_print(">>> Job status after " + str(num_tries) + " tries is "+ status)
5555
print(link_message % (str(job_id), ansibletower['url'], str(job_id)))
5656
print("\n")
5757
if status in ["running","pending","waiting"]:
@@ -65,6 +65,9 @@ def formatted_print(message):
6565
job_output=request.get(api_url+'stdout/', contentType='text/plain',headers=headers).response
6666
formatted_print(job_output)
6767
result = job_output
68+
if status in ["failed"]:
69+
formatted_print(">>> Job failed after " + str(num_tries) + " tries")
70+
raise Exception("Error: job failed")
6871
else:
6972
formatted_print(">>> Task failed after " + str(num_tries) + " tries. Job status was not retrieved.")
70-
raise Exception("Failed: Server return [%s], with content [%s]" % (response.status, response.response))
73+
raise Exception("Error: server returned [%s], with content [%s]" % (response.status, response.response))

src/plugin-version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
#SOFTWARE.
2222

2323
plugin=xlr-ansible-automation-controller-plugin
24-
version=1.1.7
24+
version=1.1.8
2525

0 commit comments

Comments
 (0)