Browse Source

Add support for prefix and link params

master
John Locke 8 years ago
parent
commit
8deb04d803
  1. 2
      README.md
  2. 9
      bin/out

2
README.md

@ -56,6 +56,8 @@ Send message to specified Matrix Room, with the configured parameters
* `data_file`: *Optional.* (string) Filename to post using a custom_event message type. If unset, defaults to the data_file on the resource. If it exists, the file must contain valid JSON.
* `trigger`: *Optional.* (string) Arbitrary test to add to a "trigger" data item on custom message types.
* `always_notify`: If true, send a notice even if text_file and data_file are empty. If false, and a text_file is specified but empty, a notification will not be sent.
* `prefix`: If set, this will be added to the beginning of a message. Commonly used with $BUILD_PIPELINE_NAME to indicate which pipeline is sending this message.
* `link`: If set to true, will wrap the text in a link to the build using the pattern $ATC_EXTERNAL_URL/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
## Example

9
bin/out

@ -40,6 +40,9 @@ thismsgtype="$(jq -r '.params.msgtype // ""' < "${payload}")"
always_notify="$(jq -r '.params.always_notify // "false"' < "${payload}")"
debug="$(jq -r '.params.debug // "false"' < "${payload}")"
silent="$(jq -r '.params.silent // "true"' < "${payload}")"
link="$(jq -r '.params.link // "false"' < "${payload}")"
prefix="$(jq -r '.params.prefix // ""' < "${payload}")"
TEXT_FILE_CONTENT=""
[[ -n "${text_file}" && -f "${text_file}" ]] && TEXT_FILE_CONTENT="$(cat "${text_file}")"
@ -54,6 +57,12 @@ then
[[ -z "${text}" ]] && text="_(missing notification text)_"
text="$(echo -n "${text}" | jq -R -s .)"
[ "${link}" == "true" ] && text="<a href=\"$ATC_EXTERNAL_URL/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\">${text}</a>"
if [ -n "$prefix" ]; then
prefix="$(eval printf ${prefix} )"
text="${prefix}: ${text}"
fi
[[ "${token}" != "null" ]] && username="$(eval "printf ${token}" | jq -R -s .)"
[[ "${room_id}" != "null" ]] && room_id="$(eval "printf ${room_id}" | jq -R -s .)"
body="$(cat <<EOF

Loading…
Cancel
Save