Browse Source

Adding simple debugging

master
Drew Short 4 years ago
parent
commit
b4b416a45c
  1. 15
      bin/out
  2. 2
      tag

15
bin/out

@ -3,6 +3,13 @@
# Send message to a matrix room. API call looks like this:
# curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "http://matrix.org/_matrix/client/api/v1/rooms/%21CvcvRuDYDzTOzfKKgh%3Alocalhost/send/m.room.message?access_token=YOUR_ACCESS_TOKEN"
log ()
{
if [[ $1 == "debug" ]]; then
echo "DEBUG: $2"
fi
}
set -e
# workaround for directory not existing before get in 3.0.0
mkdir -p "${1}"
@ -41,13 +48,14 @@ thismsgtype="$(jq -r '.params.msgtype // ""' < "${payload}")"
[[ -n $thismsgtype && $thismsgtype != $msgtype ]] && msgtype="${thismsgtype}"
always_notify="$(jq -r '.params.always_notify // "false"' < "${payload}")"
debug="$(jq -r '.params.debug // "false"' < "${payload}")"
debug="$(jq -r '.params.debug // ""' < "${payload}")"
silent="$(jq -r '.params.silent // "true"' < "${payload}")"
link="$(jq -r '.params.link // "false"' < "${payload}")"
team="$(jq -r '.params.team // "main"' < "${payload}")"
prefix="$(jq -r '.params.prefix // ""' < "${payload}")"
is_html="$(jq -r '.params.is_html // "false"' < "${payload}")"
log("$debug", "$(jq '.' < "${payload}")")
TEXT_FILE_CONTENT=""
[[ -n "${text_file}" && ! -f "${text_file}" ]] && TEXT_FILE_CONTENT="_(text_file not found)_"
@ -66,15 +74,18 @@ then
text=$(echo -en "${text}" | envsubst)
[[ -z "${text}" ]] && text="_(missing notification text)_"
# If link is set, wrap the text in a link
[ "${link}" == "true" ] && formatted_body="<a href=\"$ATC_EXTERNAL_URL/teams/${team}/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\">${text}</a>"
# If prefix is set formatted_body
if [ -n "$prefix" ]; then
prefix=$(echo "$prefix" | envsubst)
text="${prefix}: ${text}"
[ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}"
fi
if [[ "${is_html}" == "true" && -n "${formatted_body}" ]]; then
if [[ -z "${formatted_body}" && "${is_html}" == "true" ]]; then
formatted_body="${text}"
log("$debug", "formatted_body=${formatted_body}")
fi
text=$(echo -n "${text}" | jq -R -s .)

2
tag

@ -1 +1 @@
1.0.3
1.0.4
Loading…
Cancel
Save