You can send any text to a Slack channel or user, including color settings and an identifying icon. You can also send JSON payloads for the Slack Web API.
Add a Slack integration
Follow instructions to create a Slack integration. You will need to set up permissions on the Slack account to enable incoming webhooks and create an incoming webhook URL to provide this integration. Write down the friendly name that you gave your integration.
Update YAML to send notifications
You can now update your Pipeline source file.
Specify an
integrations
section with the friendly name of your Slack integration.In the
execution
section, use thesend_notification
utility function as shown below.
Sending notifications
pipelines: - name: pipe1 steps: - name: test_step_1 type: Bash configuration: integrations: - name: notifySlack # replace with friendly name of your Slack integration execution: onStart: - send_notification notifySlack --text "starting test_step_1" --recipient "#myChannel" onExecute: - send_notification notifySlack --text "in onexecute, past test commands" --recipient "@user5" onSuccess: - can use send_notification command here onFailure: - can use send_notification command here onComplete: - can use send_notification command here
You can customize additional things like username, pretext, text, payload, and more as shown in the usage description for send_notification
.