Browse Source

Update out

Use envsubst instead of eval
master
Michael Both 6 years ago
committed by GitHub
parent
commit
09690c4950
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      bin/out

10
bin/out

@ -46,7 +46,7 @@ team="$(jq -r '.params.team // "main"' < "${payload}")"
prefix="$(jq -r '.params.prefix // ""' < "${payload}")" prefix="$(jq -r '.params.prefix // ""' < "${payload}")"
TEXT_FILE_CONTENT=""
export TEXT_FILE_CONTENT=""
[[ -n "${text_file}" && -f "${text_file}" ]] && TEXT_FILE_CONTENT="$(cat "${text_file}")" [[ -n "${text_file}" && -f "${text_file}" ]] && TEXT_FILE_CONTENT="$(cat "${text_file}")"
DATA_FILE_CONTENT="" DATA_FILE_CONTENT=""
[[ -n "${data_file}" && -f "${data_file}" ]] && DATA_FILE_CONTENT="$(cat "${data_file}")" [[ -n "${data_file}" && -f "${data_file}" ]] && DATA_FILE_CONTENT="$(cat "${data_file}")"
@ -55,12 +55,12 @@ if [[ "$always_notify" == "true" || -n "$TEXT_FILE_CONTENT" || -z "$text_file" |
then then
TEXT_FILE_CONTENT="${TEXT_FILE_CONTENT:-_(no notification provided)_}" TEXT_FILE_CONTENT="${TEXT_FILE_CONTENT:-_(no notification provided)_}"
text="$(eval printf ${text} )"
text=$(echo -n "$text" | envsubst)
[[ -z "${text}" ]] && text="_(missing notification text)_" [[ -z "${text}" ]] && text="_(missing notification text)_"
[ "${link}" == "true" ] && formatted_body="<a href=\"$ATC_EXTERNAL_URL/teams/${team}/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\">${text}</a>" [ "${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 [ -n "$prefix" ]; then if [ -n "$prefix" ]; then
prefix="$(eval printf ${prefix} )"
prefix=$(echo "$prefix" | envsubst)
text="${prefix}: ${text}" text="${prefix}: ${text}"
[ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}" [ -n "${formatted_body}" ] && formatted_body="${prefix}: ${formatted_body}"
fi fi
@ -68,8 +68,8 @@ then
text="$(echo -n "${text}" | jq -R -s .)" text="$(echo -n "${text}" | jq -R -s .)"
[ -n "${formatted_body}" ] && formatted_body="$(echo -n "${formatted_body}" | jq -R -s .)" [ -n "${formatted_body}" ] && formatted_body="$(echo -n "${formatted_body}" | jq -R -s .)"
[[ "${token}" != "null" ]] && username="$(eval "printf ${token}" | jq -R -s .)"
[[ "${room_id}" != "null" ]] && room_id="$(eval "printf ${room_id}" | jq -R -s .)"
[[ "${token}" != "null" ]] && username=$(echo "$token" | envsubst | jq -R -s .)"
[[ "${room_id}" != "null" ]] && room_id=$(echo "$room_id" | envsubst | jq -R -s .)"
body="$(cat <<EOF body="$(cat <<EOF
{ {
"msgtype": "${msgtype}", "msgtype": "${msgtype}",

Loading…
Cancel
Save