Create a Slack web trigger
You can create a web trigger to connect Unity Version Control with Slack to receive notifications. The notification includes the information available to the specific trigger that you use.
Configure Slack
To configure Slack, you first need to make a Slack application with the correct scopes:
- In the Apps section, select Add apps > App Directory.
- In the browser that opens, select Build > Your Apps.
- Select Create an App > From scratch.
- Add the name of your app, select the workspace you want to use, and select Create App.
- Select Bots to add bot functionality and then select Review scopes to add.
- Add the following scopes:
channels:read
chat:write
groups:read
im:read
mpim:read
users:read
- Select Install to Workspace or Request to Install, dependent on your workspace permissions, and make a note of the Bot User OAuth Token that generates.
Once you install your app to your workspace, you can set it up and get the information you need in your Slack application:
- In the Apps section, select Add apps > App Directory, search for your app and select it.
- Right-click on the app and select View app details.
- Select Add this app to a channel and select the channel you want to use from the dropdown.
Make the web trigger
To create the Slack web trigger, you need the Bot User OAuth Token from when you install your app into Slack, and the channel name of the channel you added the app to.
You need to use the webtrigger-slack
string (instead of webtrigger
) before the script path, followed by the Slack channel:
webtrigger-slack https://slack.com/api/chat.postMessage/${channelOrUserId}/${slackBotToken}
Example Slack web triggers
The trigger below causes the server to post a message to Slack after every check in made in the server myPlasticServer
. The message includes details such as the check in comment, the check in author, and the specification of the changeset the operation created.
cm trigger make after-checkin MySlackAfterCheckinTrigger "webtrigger-slack https://slack.com/api/chat.postMessage/<channelId or UserId>/xoxb-SlackBotToken" --server=myPlasticServer
cm trigger edit after-checkin 3 "webtrigger-slack https://slack.com/api/chat.postMessage/<channelId or UserId>/xoxb-SlackBotToken"