diff --git a/build.gradle b/build.gradle index 6e8eeed..f1fe1e9 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { defaultTasks 'build' apply plugin: 'java' -version='1.1.7' +version='1.1.8' sourceSets.main.resources.srcDirs = ["src"] license { diff --git a/src/ansibletower/launchAndWait.py b/src/ansibletower/launchAndWait.py index 17551a2..20bd9ae 100644 --- a/src/ansibletower/launchAndWait.py +++ b/src/ansibletower/launchAndWait.py @@ -28,9 +28,12 @@ def create_payload(extra_vars, jobTags, credentials): body = {} - body['extra_vars'] = extra_vars - body['job_tags'] = ",".join(jobTags) - body['credentials'] = credentials + if extra_vars: + body['extra_vars'] = extra_vars + if jobTags: + body['job_tags'] = ",".join(jobTags) + if credentials: + body['credentials'] = credentials body_as_string = json.dumps(body) print "Body returned from create_payload() is %s" % body_as_string return body_as_string diff --git a/src/ansibletower/launchAndWait.wait_for_completion.py b/src/ansibletower/launchAndWait.wait_for_completion.py index a2ef6c6..528af15 100644 --- a/src/ansibletower/launchAndWait.wait_for_completion.py +++ b/src/ansibletower/launchAndWait.wait_for_completion.py @@ -51,7 +51,7 @@ def formatted_print(message): result = json.loads(response.response) status=result['status'] task.setStatusLine("Job id %s %s" % (job_id, status)) - formatted_print(">>> Task status after " + str(num_tries) + " tries is "+ status) + formatted_print(">>> Job status after " + str(num_tries) + " tries is "+ status) print(link_message % (str(job_id), ansibletower['url'], str(job_id))) print("\n") if status in ["running","pending","waiting"]: @@ -65,6 +65,9 @@ def formatted_print(message): job_output=request.get(api_url+'stdout/', contentType='text/plain',headers=headers).response formatted_print(job_output) result = job_output + if status in ["failed"]: + formatted_print(">>> Job failed after " + str(num_tries) + " tries") + raise Exception("Error: job failed") else: formatted_print(">>> Task failed after " + str(num_tries) + " tries. Job status was not retrieved.") - raise Exception("Failed: Server return [%s], with content [%s]" % (response.status, response.response)) + raise Exception("Error: server returned [%s], with content [%s]" % (response.status, response.response)) diff --git a/src/plugin-version.properties b/src/plugin-version.properties index af2813a..2a5ab1d 100644 --- a/src/plugin-version.properties +++ b/src/plugin-version.properties @@ -21,5 +21,5 @@ #SOFTWARE. plugin=xlr-ansible-automation-controller-plugin -version=1.1.7 +version=1.1.8