With our Slack integration, not only can you send a notification to a channel when a deployment has started or finished, you can even trigger a deployment straight from your Slack client. You'll be able to start and monitor deployments from the comfort of Slack without having to load up the DeployHQ interface separately.
Setting up Slack
To get started, head to the Integrations page in any project, then click New Integration and choose Slack in the service picker.
Then, you'll be able to add a message format (we recommend using the default, and leaving the rich text option enabled), choose when to trigger the notification, and which servers you want to notify for.
Once you've done that, simply click Create Integration and you'll be redirected to login to Slack and authorise DeployHQ.
Once you've clicked Authorize, you will be able to add the integration to any project, and start using Slack to trigger your deployments.
According to your notification settings in a given project, DeployHQ will send a notification to the appropriate Slack channel in up to 3 different scenarios.
- When a deployment starts
- If a deployment finishes successfully
- If a deployment fails
The notification will be extremely similar for each scenario, but will display a number of useful pieces of information about the deployment in your Slack channel.
In the example above, you can see the commit message, status, and server name, as well as the start and end revisions. Clicking either revision will take you straight to the appropriate page in your repository host's web interface to view it, and clicking the notification subject will take you to the deployment report in DeployHQ.
Triggering a deployment using Slackbot
Once you've authorised access in Slack, you'll be able to use a number of commands in your Slack client to interact with your DeployHQ account.
Start by typing:
This will display a list of available commands.
/deployhq list command will display a list of projects that you have access to and can deploy.
If the user executing the command doesn't have full access to the account, they'll only be shown projects that they've been granted permissions to deploy.
To then trigger the deployment, simply type
/deployhq deploy api-test where
api-test is the permalink of your project. Once you've done that, you'll be given the option to customise or deploy now:
If you have more than one server, you can click Customize to select a different server, but in this case as we only have a single server, we'll just click Deploy Now!
As we've configured the notification on this project to send when the deployment is started, we firstly receive a notification in our configured Slack channel, that shows the deployment is running:
Then once it has finished, we'll receive another notification.
So we've now completed adding Slack to our DeployHQ account to both receive notifications about deployments when they're started and completed, and trigger them straight from a Slack channel.