From 067c30ba9c540a2339a268243827e2f1b0f58508 Mon Sep 17 00:00:00 2001 From: Martin Stiborsky Date: Wed, 5 Sep 2018 11:33:23 +0200 Subject: [PATCH] script fail if curl call to confluence doesn't return http 200 --- update-confluence | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/update-confluence b/update-confluence index 7b920eb..3e006c5 100755 --- a/update-confluence +++ b/update-confluence @@ -20,7 +20,7 @@ next_version=$(curl -u ${JIRA_USER}:${JIRA_PASSWORD} -X GET -H 'Content-Type: ap mdtohtml ${SOURCE_FILE} /tmp/__${FNAME} -curl -u ${JIRA_USER}:${JIRA_PASSWORD} -X PUT -H 'Content-Type: application/json' https://hcpeer2peer.atlassian.net/wiki/rest/api/content/${ID} \ +status_code=$(curl --silent --output /dev/stderr --write-out "%{http_code}" -u ${JIRA_USER}:${JIRA_PASSWORD} -X PUT -H 'Content-Type: application/json' https://hcpeer2peer.atlassian.net/wiki/rest/api/content/${ID} \ -d @- << EOF { "id": "${ID}", @@ -37,3 +37,13 @@ curl -u ${JIRA_USER}:${JIRA_PASSWORD} -X PUT -H 'Content-Type: application/json' } } EOF +) + +echo "Confluence update status_code: ${status_code}" + +if test $status_code -ne 200; then + exit 1 +fi + +exit 0 +