mirror of
https://github.com/yavook/kiwi-backup.git
synced 2024-11-22 15:03:01 +00:00
most basic URL encoding; actually use run_webhook
This commit is contained in:
parent
6803211e48
commit
58cf8b79f5
1 changed files with 13 additions and 20 deletions
|
@ -19,29 +19,24 @@ if [ -n "${GPG_PASSPHRASE}" ]; then
|
||||||
unset GPG_PASSPHRASE
|
unset GPG_PASSPHRASE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run_webhook() {
|
run_webhook() { #url #message
|
||||||
_rw_webhook_url="${1}"
|
if [ -z "${WEBHOOK_URL}" ]; then
|
||||||
_rw_message="${2}"
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_rw_message="$(echo "${2}" | sed "s,\s,%20,g" )"
|
||||||
|
_rw_webhook_url="$(echo "${1}" | sed "s,%%MSG%%,${_rw_message},g" )"
|
||||||
|
|
||||||
_rw_curl_args=""
|
_rw_curl_args=""
|
||||||
if [ "${WEBHOOK_INSECURE}" = "1" ]; then
|
if [ "${WEBHOOK_INSECURE}" = "1" ]; then
|
||||||
_rw_curl_args="--insecure"
|
_rw_curl_args="--insecure"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_rw_webhook_url="$(echo "${_rw_webhook_url}" | sed "s,%%MSG%%,,g" )"
|
|
||||||
curl ${_rw_curl_args} "${_rw_webhook_url}" 1>/dev/null 2>/dev/null
|
curl ${_rw_curl_args} "${_rw_webhook_url}" 1>/dev/null 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# run start webhook
|
# run start webhook
|
||||||
curl_args=""
|
run_webhook "${WEBHOOK_URL}" "running task ${*}"
|
||||||
if [ "${WEBHOOK_INSECURE}" = "1" ]; then
|
|
||||||
curl_args="--insecure"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${WEBHOOK_URL}" ]; then
|
|
||||||
webhook_url="$(echo "${WEBHOOK_URL}" | sed "s,%%MSG%%,running%20task%20${*},g" )"
|
|
||||||
curl ${curl_args} "${webhook_url}" 1>/dev/null 2>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# hand over
|
# hand over
|
||||||
set -ex
|
set -ex
|
||||||
|
@ -49,15 +44,13 @@ eval "$( \
|
||||||
"${this_dir}/build_command" \
|
"${this_dir}/build_command" \
|
||||||
"${@}" \
|
"${@}" \
|
||||||
)"
|
)"
|
||||||
exit_code="${?}"
|
exit_status="${?}"
|
||||||
|
|
||||||
# run finish webhook
|
# run finish webhook
|
||||||
if [ "${exit_code}" -eq "0" ] && [ -n "${WEBHOOK_URL}" ]; then
|
if [ "${exit_status}" -eq "0" ]; then
|
||||||
webhook_url="$(echo "${WEBHOOK_URL}" | sed "s,%%MSG%%,task%20${*}%20finished%20successfully,g" )"
|
run_webhook "${WEBHOOK_URL}" "task ${*} successful"
|
||||||
curl ${curl_args} "${webhook_url}" 1>/dev/null 2>/dev/null
|
|
||||||
|
|
||||||
elif [ "${exit_code}" -ne "0" ] && [ -n "${WEBHOOK_URL}" ]; then
|
else
|
||||||
webhook_fail_url="$(echo "${WEBHOOK_FAIL_URL:-${WEBHOOK_URL}}" | sed "s,%%MSG%%,task%20${*}%20finished%20with%20status%20${exit_code},g" )"
|
run_webhook "${WEBHOOK_FAIL_URL:-${WEBHOOK_URL}}" "task ${*} failed, status ${exit_status}"
|
||||||
curl ${curl_args} "${webhook_fail_url}" 1>/dev/null 2>/dev/null
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue