|
5 | 5 |
|
6 | 6 | # Slack notifications |
7 | 7 |
|
| 8 | +Slack notifications allow you to receive real-time updates about your Semaphore workflows directly in your Slack channels. This integration helps teams stay informed about build statuses, deployment results, and other important events without having to constantly check the Semaphore dashboard. |
| 9 | + |
| 10 | +To set up Slack notifications, you need to create a webhook URL that connects Semaphore to your desired Slack channel. This webhook acts as a secure communication bridge between the two platforms. |
| 11 | + |
| 12 | +## Creating Slack webhook |
| 13 | + |
| 14 | +### Step 1. Open Slack API settings |
| 15 | + |
| 16 | +1. Go to [https://api.slack.com/apps](https://api.slack.com/apps). |
| 17 | +2. Click **Create New App** → choose **From Scratch**. |
| 18 | +3. Give your app a name (e.g., `Semaphore Bot`) and select your **Slack workspace**. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +### Step 2. Enable incoming webhooks |
| 23 | + |
| 24 | +1. Inside the app settings, go to **Features → Incoming Webhooks**. |
| 25 | +2. Switch **ctivate Incoming Webhooks** → **On**. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +### Step 3. Create a webhook URL |
| 30 | + |
| 31 | +1. Click **dd New Webhook to Workspace**. |
| 32 | +2. Select the xxchannelxx where messages should be sent. |
| 33 | +3. Click **Allow**. |
| 34 | +4. You’ll see a **Webhook URL** like: |
| 35 | + |
| 36 | + ``` |
| 37 | + https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx |
| 38 | + ``` |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +### Step 4. Test your webhook |
| 43 | + |
| 44 | +Use `curl` to test: |
| 45 | + |
| 46 | +```bash |
| 47 | +curl -X POST -H 'Content-type: application/json' \ |
| 48 | +--data '{"text":"Hello from Semaphore UI 🚀"}' \ |
| 49 | +https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx |
| 50 | +``` |
| 51 | + |
| 52 | +If everything is set up, you’ll see the message in the selected Slack channel. |
| 53 | + |
| 54 | + |
| 55 | +## Semaphore configuration |
| 56 | + |
| 57 | +Once you have your Slack webhook URL, you can configure Semaphore to send notifications in several ways: |
| 58 | + |
| 59 | +You can enable Slack notifications using either configuration files or environment variables. |
| 60 | + |
| 61 | +### Method 1: Configuration file |
| 62 | + |
| 63 | +Add the following settings to your Semaphore configuration file: |
| 64 | + |
| 65 | +- `slack_alert`: Set to `true` to enable Slack notifications |
| 66 | +- `slack_url`: Your webhook URL from the previous step |
| 67 | + |
8 | 68 | `config.json` example: |
9 | 69 |
|
10 | 70 | ```json |
11 | 71 | { |
12 | 72 | "slack_alert": true, |
13 | | - "slack_url": "...", |
| 73 | + "slack_url": "https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx", |
14 | 74 | } |
| 75 | +``` |
| 76 | + |
| 77 | +### Method 2: Environment variables |
| 78 | + |
| 79 | +Alternatively, you can use environment variables to configure Slack notifications. This method is particularly useful for containerized deployments or when you want to keep sensitive information separate from configuration files. |
| 80 | + |
| 81 | +``` |
| 82 | +SEMAPHORE_SLACK_ALERT=True |
| 83 | +SEMAPHORE_SLACK_URL=https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx |
15 | 84 | ``` |
0 commit comments