File tree Expand file tree Collapse file tree 5 files changed +49
-4
lines changed
Expand file tree Collapse file tree 5 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,31 @@ Set the `scheduled_offset_seconds` special parameter to a number of seconds if y
151151 }
152152 ` ` `
153153
154+ # # GovSlack Support
155+
156+ Set the `api_domain` parameter to specify which Slack API domain to use. Use `slack.com` for regular Slack workspaces (default) and `slack-gov.com` for GovSlack workspaces.
157+
158+ ` ` ` yaml
159+ - slack/notify:
160+ event: always
161+ api_domain: slack-gov.com
162+ custom: |
163+ {
164+ "blocks": [
165+ {
166+ "type": "section",
167+ "fields": [
168+ {
169+ "type": "plain_text",
170+ "text": "*This is a text notification to GovSlack*",
171+ "emoji": true
172+ }
173+ ]
174+ }
175+ ]
176+ }
177+ ` ` `
178+
154179
155180---
156181
Original file line number Diff line number Diff line change @@ -116,6 +116,11 @@ parameters:
116116 When this command is going to be run on windows, set this to true.
117117 type : boolean
118118 default : false
119+ api_domain :
120+ description : |
121+ Domain for the Slack API. Use slack.com for regular Slack and slack-gov.com for GovSlack.
122+ type : string
123+ default : " slack.com"
119124steps :
120125 - run :
121126 when : on_fail
@@ -161,6 +166,7 @@ steps:
161166 SLACK_PARAM_OFFSET : " <<parameters.scheduled_offset_seconds>>"
162167 SLACK_PARAM_UNFURL_LINKS : " <<parameters.unfurl_links>>"
163168 SLACK_PARAM_UNFURL_MEDIA : " <<parameters.unfurl_media>>"
169+ SLACK_PARAM_API_DOMAIN : " <<parameters.api_domain>>"
164170 SLACK_SCRIPT_NOTIFY : " <<include(scripts/notify.sh)>>"
165171 SLACK_SCRIPT_UTILS : " <<include(scripts/utils.sh)>>"
166172 # import pre-built templates using the orb-pack local script include.
@@ -195,6 +201,7 @@ steps:
195201 SLACK_PARAM_OFFSET : " <<parameters.scheduled_offset_seconds>>"
196202 SLACK_PARAM_UNFURL_LINKS : " <<parameters.unfurl_links>>"
197203 SLACK_PARAM_UNFURL_MEDIA : " <<parameters.unfurl_media>>"
204+ SLACK_PARAM_API_DOMAIN : " <<parameters.api_domain>>"
198205 SLACK_SCRIPT_NOTIFY : " <<include(scripts/notify.sh)>>"
199206 SLACK_SCRIPT_UTILS : " <<include(scripts/utils.sh)>>"
200207 # import pre-built templates using the orb-pack local script include.
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ parameters:
5252 When this command is going to be run on windows, set this to true.
5353 type : boolean
5454 default : false
55+ api_domain :
56+ description : |
57+ Domain for the Slack API. Use slack.com for regular Slack and slack-gov.com for GovSlack.
58+ type : string
59+ default : " slack.com"
5560steps :
5661 - when :
5762 condition :
7176 SLACK_PARAM_INVERT_MATCH : <<parameters.invert_match>>
7277 SLACK_PARAM_THREAD : <<parameters.thread_id>>
7378 SLACK_PARAM_DEBUG : << parameters.debug >>
79+ SLACK_PARAM_API_DOMAIN : << parameters.api_domain >>
7480 SLACK_SCRIPT_UTILS : " <<include(scripts/utils.sh)>>"
7581 - when :
7682 condition :
9197 SLACK_PARAM_INVERT_MATCH : <<parameters.invert_match>>
9298 SLACK_PARAM_THREAD : <<parameters.thread_id>>
9399 SLACK_PARAM_DEBUG : << parameters.debug >>
100+ SLACK_PARAM_API_DOMAIN : << parameters.api_domain >>
94101 SLACK_SCRIPT_UTILS : " <<include(scripts/utils.sh)>>"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22# shellcheck disable=SC2016,SC3043
3+
4+ # Set API_DOMAIN from parameter or default to slack.com
5+ API_DOMAIN=" ${SLACK_PARAM_API_DOMAIN:- slack.com} "
36if [[ " $SLACK_PARAM_CUSTOM " == \$ * ]]; then
47 echo " Doing substitution custom"
58 SLACK_PARAM_CUSTOM=" $( eval echo " ${SLACK_PARAM_CUSTOM} " | circleci env subst) "
@@ -141,9 +144,9 @@ PostToSlack() {
141144 SLACK_MSG_BODY=$( echo " $SLACK_MSG_BODY " | jq --arg post_at " $POST_AT " ' .post_at = ($post_at|tonumber)' )
142145 # text is required for scheduled messages
143146 SLACK_MSG_BODY=$( echo " $SLACK_MSG_BODY " | jq ' .text = "Dummy fallback text"' )
144- NotifyWithRetries https://slack.com /api/chat.scheduleMessage
147+ NotifyWithRetries https://" $API_DOMAIN " /api/chat.scheduleMessage
145148 else
146- NotifyWithRetries https://slack.com /api/chat.postMessage
149+ NotifyWithRetries https://" $API_DOMAIN " /api/chat.postMessage
147150 fi
148151
149152 if [ " $SLACK_PARAM_DEBUG " -eq 1 ]; then
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+
3+ # Set API_DOMAIN from parameter or default to slack.com
4+ API_DOMAIN=" ${SLACK_PARAM_API_DOMAIN:- slack.com} "
25if [ " $SLACK_PARAM_DEBUG " = 1 ]; then
36 set -x
47fi
@@ -29,7 +32,7 @@ ReactToSlack() {
2932
3033 if [ -n " ${SLACK_PARAM_REMOVE_REACT_NAME} " ]; then
3134 echo " Remove reaction with name=${SLACK_PARAM_REMOVE_REACT_NAME} channel=${SLACK_PARAM_CHANNEL} thread_ts=${SLACK_THREAD_TS} "
32- REMOVE_RESULT=$( curl -X POST --location ' https://slack.com /api/reactions.remove' \
35+ REMOVE_RESULT=$( curl -X POST --location " https://$API_DOMAIN /api/reactions.remove" \
3336 --header ' Content-Type: application/x-www-form-urlencoded' \
3437 --header " Authorization: Bearer ${SLACK_ACCESS_TOKEN} " \
3538 --data-urlencode " channel=${SLACK_PARAM_CHANNEL} " \
@@ -42,7 +45,7 @@ ReactToSlack() {
4245 fi
4346 if [ -n " ${SLACK_PARAM_ADD_REACT_NAME} " ]; then
4447 echo " Add reaction with name=${SLACK_PARAM_ADD_REACT_NAME} channel=${SLACK_PARAM_CHANNEL} thread_ts=${SLACK_THREAD_TS} "
45- ADD_RESULT=$( curl -X POST --location ' https://slack.com /api/reactions.add' \
48+ ADD_RESULT=$( curl -X POST --location " https://$API_DOMAIN /api/reactions.add" \
4649 --header ' Content-Type: application/x-www-form-urlencoded' \
4750 --header " Authorization: Bearer ${SLACK_ACCESS_TOKEN} " \
4851 --data-urlencode " channel=${SLACK_PARAM_CHANNEL} " \
You can’t perform that action at this time.
0 commit comments