File tree 5 files changed +27
-4
lines changed
5 files changed +27
-4
lines changed Original file line number Diff line number Diff line change
1
+ # Bug Fixes
2
+
3
+ - The ` text ` field of attachments now interpolates environment
4
+ variables from the container environment (i.e. BUILD_ * et al).
5
+ Fixes #25
Original file line number Diff line number Diff line change 68
68
if [[ " ${attachments} " == " null" ]]
69
69
then
70
70
TEXT_FILE_CONTENT=" ${TEXT_FILE_CONTENT:- _(no notification provided)_} "
71
+ else
72
+ # we have attachments; better interpolate the `text' field...
73
+ workfile=$( mktemp /tmp/attach.XXXXXX)
74
+ outfile=$( mktemp /tmp/attach.XXXXXX)
75
+ cat > $workfile <<< $attachments
76
+ for x in $( seq 1 $( jq -r ' length' < $workfile ) ) ; do
77
+ x=$(( x - 1 ))
78
+ if [[ $x != 0 ]]; then
79
+ echo -n " ," >> $outfile
80
+ fi
81
+ attachment_text=" $( jq -r " .[$x ].text // " ' ""' < $workfile ) "
82
+ interpolated=' {}'
83
+ if [[ -n " $attachment_text " ]]; then
84
+ interpolated=" $( echo $( eval printf " %b" \" " $attachment_text " \" | jq -R ' {"text":.}' ) ) "
85
+ fi
86
+ jq -s ' .[0] * .[1]' <( jq -r " .[$x ]" < $workfile ) <( echo " $interpolated " ) >> $outfile
87
+ done
88
+ attachments=$(( echo '['; cat $outfile ; echo ']') | jq - r .)
71
89
fi
72
90
73
91
text="$(eval printf "%b" ${text} )"
Original file line number Diff line number Diff line change @@ -145,13 +145,13 @@ test metadata_with_payload | jq -e "
145
145
test attachments_no_text | jq -e "
146
146
.body.text == null and
147
147
.body.attachments[0].color == \" danger\" and
148
- .body.attachments[0].text == \" Build failed!\" and
148
+ .body.attachments[0].text == \" Build my-build failed!\" and
149
149
( .body.attachments | length == 1 )"
150
150
151
151
test attachments_with_text | jq -e "
152
152
.body.text == \" Inline static text\n\" and
153
153
.body.attachments[0].color == \" danger\" and
154
- .body.attachments[0].text == \" Build failed!\" and
154
+ .body.attachments[0].text == \" Build my-build failed!\" and
155
155
( .body.attachments | length == 1 )"
156
156
157
157
test multiple_channels | jq -e "
Original file line number Diff line number Diff line change 6
6
"attachments": [
7
7
{
8
8
"color": "danger",
9
- "text": "Build failed!"
9
+ "text": "Build $BUILD_NAME failed!"
10
10
}
11
11
]
12
12
},
Original file line number Diff line number Diff line change 7
7
"attachments": [
8
8
{
9
9
"color": "danger",
10
- "text": "Build failed!"
10
+ "text": "Build $BUILD_NAME failed!"
11
11
}
12
12
]
13
13
},
You can’t perform that action at this time.
0 commit comments