Are you tired of constantly monitoring your terminal to check if your build is complete? Worry not! Slack web hooks can assist you with that.
In this document, we will explain how to set up Slack web hooks. These web hooks can be utilized to send a Slack message informing you about the status of your command once it has finished running.
- pick a name, choose a workspace to associate your app with. For our case it can be my-notification
After creating, you'll be redirected to the settings page for your new app, then select the Incoming Webhooks feature, and click the Activate Incoming Webhooks toggle to switch it on.
On the bottom of the page, click on “Request to Add New Webhook” - write the purpose of the webhook - in our case it could be “Webhook used for notifying me about my local builds/command when it's finished”. This will create a request on
slack channel. Wait for approval, typically it takes few minutes.
After your request is approved, go back to your Slack app’s Incoming Webhooks page. At the bottom of the page, click on “Add New Webhook to Workspace” - choose a channel that you want the Slack web hook to send notifications to. I suggest to search for yourself (yes! as the channel) and click Allow.
Congratulation, now you have a Webhook URL - it should look something like
Copy-paste this function in your beloved .rc file (i.e .zshrc) and source it
functionnotify(){
WEBHOOK_URL="PASTE_YOUR_WEBHOOK_URL"
"$@"
cmd_status=$?
if[$cmd_status-eq0]
then
curl-X POST -H'Content-type: application/json'--data'{"text":"Success!"}'$WEBHOOK_URL
else
curl-X POST -H'Content-type: application/json'--data'{"text":"Failed!"}'$WEBHOOK_URL
fi
}
7. You are all setup! Let’s test it. You have to prefix the shell command you want to monitor with notify and it will send you a slack message when it’s done. For example, it can be used for monitoring long builds notify newt build
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (