@@ -102,93 +102,171 @@ ${TICKET_LINES[$i]}"
102102 # Build JSON payload using jq for proper escaping
103103 if [ $msg_num -eq 1 ]; then
104104 # First message with full header
105- SLACK_PAYLOAD=$( jq -n \
106- --arg emoji " $EMOJI " \
107- --arg title " $TITLE_TEXT " \
108- --arg app " $REPOSITORY_NAME " \
109- --arg env " $ENVIRONMENT " \
110- --arg msg " $MESSAGE_TEXT " \
111- --arg tickets " $TICKET_DETAILS " \
112- --arg pr_url " ${PR_URL:- } " \
113- ' {
114- blocks: [
115- {
116- type: "header",
117- text: {
118- type: "plain_text",
119- text: ($emoji + " " + $title),
120- emoji: true
121- }
122- },
123- {
124- type: "section",
125- fields: [
126- {
105+ if [ -n " $PR_URL " ]; then
106+ SLACK_PAYLOAD=$( jq -n \
107+ --arg emoji " $EMOJI " \
108+ --arg title " $TITLE_TEXT " \
109+ --arg app " $REPOSITORY_NAME " \
110+ --arg env " $ENVIRONMENT " \
111+ --arg msg " $MESSAGE_TEXT " \
112+ --arg tickets " $TICKET_DETAILS " \
113+ --arg pr_url " $PR_URL " \
114+ ' {
115+ blocks: [
116+ {
117+ type: "header",
118+ text: {
119+ type: "plain_text",
120+ text: ($emoji + " " + $title),
121+ emoji: true
122+ }
123+ },
124+ {
125+ type: "section",
126+ fields: [
127+ {
128+ type: "mrkdwn",
129+ text: ("*Application:*\n`" + $app + "`")
130+ },
131+ {
132+ type: "mrkdwn",
133+ text: ("*Environment:*\n`" + $env + "`")
134+ }
135+ ]
136+ },
137+ {
138+ type: "divider"
139+ },
140+ {
141+ type: "section",
142+ text: {
143+ type: "mrkdwn",
144+ text: $msg
145+ }
146+ },
147+ {
148+ type: "section",
149+ text: {
127150 type: "mrkdwn",
128- text: ("*Application:*\n`" + $app + "`")
129- },
130- {
151+ text: $tickets
152+ }
153+ },
154+ {
155+ type: "section",
156+ text: {
131157 type: "mrkdwn",
132- text: ("*Environment:*\n` " + $env + "` ")
158+ text: ("< " + $pr_url + "|View Pull Request> ")
133159 }
134- ]
135- },
136- {
137- type: "divider"
138- },
139- {
140- type: "section",
141- text: {
142- type: "mrkdwn",
143- text: $msg
144160 }
145- },
146- {
147- type: "section",
148- text: {
149- type: "mrkdwn",
150- text: $tickets
161+ ]
162+ }' )
163+ else
164+ SLACK_PAYLOAD=$( jq -n \
165+ --arg emoji " $EMOJI " \
166+ --arg title " $TITLE_TEXT " \
167+ --arg app " $REPOSITORY_NAME " \
168+ --arg env " $ENVIRONMENT " \
169+ --arg msg " $MESSAGE_TEXT " \
170+ --arg tickets " $TICKET_DETAILS " \
171+ ' {
172+ blocks: [
173+ {
174+ type: "header",
175+ text: {
176+ type: "plain_text",
177+ text: ($emoji + " " + $title),
178+ emoji: true
179+ }
180+ },
181+ {
182+ type: "section",
183+ fields: [
184+ {
185+ type: "mrkdwn",
186+ text: ("*Application:*\n`" + $app + "`")
187+ },
188+ {
189+ type: "mrkdwn",
190+ text: ("*Environment:*\n`" + $env + "`")
191+ }
192+ ]
193+ },
194+ {
195+ type: "divider"
196+ },
197+ {
198+ type: "section",
199+ text: {
200+ type: "mrkdwn",
201+ text: $msg
202+ }
203+ },
204+ {
205+ type: "section",
206+ text: {
207+ type: "mrkdwn",
208+ text: $tickets
209+ }
151210 }
152- }
153- ] + (if $pr_url != "" then [{
154- type: "section",
155- text: {
156- type: "mrkdwn",
157- text: ("<" + $pr_url + "|View Pull Request>")
158- }
159- }] else [] end)
160- }' )
211+ ]
212+ }' )
213+ fi
161214 else
162215 # Subsequent messages with part number
163216 PART_TEXT=" *Part ${msg_num} /${TOTAL_MESSAGES} *"
164- SLACK_PAYLOAD=$( jq -n \
165- --arg part " $PART_TEXT " \
166- --arg tickets " $TICKET_DETAILS " \
167- --arg pr_url " ${PR_URL:- } " \
168- ' {
169- blocks: [
170- {
171- type: "section",
172- text: {
173- type: "mrkdwn",
174- text: $part
217+ if [ -n " $PR_URL " ]; then
218+ SLACK_PAYLOAD=$( jq -n \
219+ --arg part " $PART_TEXT " \
220+ --arg tickets " $TICKET_DETAILS " \
221+ --arg pr_url " $PR_URL " \
222+ ' {
223+ blocks: [
224+ {
225+ type: "section",
226+ text: {
227+ type: "mrkdwn",
228+ text: $part
229+ }
230+ },
231+ {
232+ type: "section",
233+ text: {
234+ type: "mrkdwn",
235+ text: $tickets
236+ }
237+ },
238+ {
239+ type: "section",
240+ text: {
241+ type: "mrkdwn",
242+ text: ("<" + $pr_url + "|View Pull Request>")
243+ }
175244 }
176- },
177- {
178- type: "section",
179- text: {
180- type: "mrkdwn",
181- text: $tickets
245+ ]
246+ }' )
247+ else
248+ SLACK_PAYLOAD=$( jq -n \
249+ --arg part " $PART_TEXT " \
250+ --arg tickets " $TICKET_DETAILS " \
251+ ' {
252+ blocks: [
253+ {
254+ type: "section",
255+ text: {
256+ type: "mrkdwn",
257+ text: $part
258+ }
259+ },
260+ {
261+ type: "section",
262+ text: {
263+ type: "mrkdwn",
264+ text: $tickets
265+ }
182266 }
183- }
184- ] + (if $pr_url != "" then [{
185- type: "section",
186- text: {
187- type: "mrkdwn",
188- text: ("<" + $pr_url + "|View Pull Request>")
189- }
190- }] else [] end)
191- }' )
267+ ]
268+ }' )
269+ fi
192270 fi
193271
194272 # Send to Slack
0 commit comments