cloudfoundry-community / slack-notification-resource

Concourse CI resource for sending notifications to Slack.
MIT License
75 stars 82 forks source link

empty or missing text_file causes dropped notification #46

Closed dyroberts closed 6 years ago

dyroberts commented 6 years ago

steps to reproduce:

expected: each job produces a slack notification in the specified channel actual: no notifications are produced

matthope commented 6 years ago

Looks like the "simplest" fix for this is:

--- a/out
+++ b/out
@@ -53,6 +53,7 @@ then
 fi

 export TEXT_FILE_CONTENT=""
+[[ -n "${text_file}" && ! -f "${text_file}" ]] && text_file=""
 [[ -n "${text_file}" && -f "${text_file}" ]] && TEXT_FILE_CONTENT="$(cat "${text_file}")"

 ATTACHMENTS_FILE_CONTENT=""

There is a check to see if the file exists before setting "TEXT_FILE_CONTENT", but later checks are just if the value is set, not if it exists.

In my testing, this addresses both example jobs provided.

jhunt commented 6 years ago

Merged in #47