@@ 13,16 13,22 @@ playbook_name = sys.argv[1]
playbook = "playbooks/" + playbook_name + ".yml"
r = ansible_runner.run(private_data_dir=".", playbook=playbook)
-changes = list(r.stats["changed"].values())[0]
-message = "[Playbook]({}) deployed with **{}** changes."
build_url = environ["JOB_URL"]
gotify_token = environ["GOTIFY_TOKEN"]
+changes_list = list(r.stats["changed"].values())
+changes = 0
+
+if len(changes_list) > 0:
+ changes = changes_list[0]
+if changes == 0:
+ sys.exit()
+message = "[Playbook]({}) deployed with **{}** changes.".format(build_url, changes)
if changes > 0:
post(
"https://gotify.xenrox.net/message?token=" + gotify_token,
json={
- "message": message.format(build_url, changes),
+ "message": message,
"priority": 7,
"Title": playbook_name + " status",
"extras": {