Knowledge

How to send notifications and use slash commands with Slack?

Integrating Buddy with Slack will keep your team updated with automatic notifications on finished builds and deployments to a Slack channel. You can also use it to trigger and get the status of your pipelines with slash commands.

Send messages to a Slack channel

You can configure Buddy to automatically send messages to the desired Slack channel. All you need to do is add the dedicated action to your pipeline:

  1. Create or update a pipeline and add Slack notification to the action list
  2. Sign in to your Slack team
  3. Authorize Buddy to access Slack
  4. Select the channel to which you want to send notifications
  5. Type the Contents of the message
  6. Click the button to Test & Save change

You can use parameters to specify the variables within the message. The default notification looks like this:

    ${execution.pipeline.name} execution #${execution.id}

Which basically translates to a message like this:

    Upload to FTP execution #12
Configuring Slack action (click to enlarge)
Configuring Slack action (click to enlarge)

Notification parameters

You can use these parameters in the message contents:

${workspace.html_url}
${workspace.name}
${workspace.domain}
${invoker.avatar_url}
${invoker.email}
${project.html_url}
${project.name}cd
${project.display_name}
${project.repository_type}
${execution.id}
${execution.html_url}
${execution.start_date}
${execution.automatic}
${execution.refresh}
${execution.status}
${execution.comment}
${execution.pipeline.html_url}
${execution.pipeline.name}
${execution.branch}

You can fetch more variables from the release object using:

${execution.action_executions.get(0).to_revision}

Here's an example execution object:

{
  "workspace": {
    "url": "https://api.buddy.works/workspaces/buddy",
    "html_url": "https://app.buddy.works/buddy",
    "id": 200000,
    "name": "buddy",
    "domain": "buddy"
  },
  "invoker": {
    "url": "https://app.buddy.works/buddy/member/1",
    "html_url": "https://app.buddy.works/buddy/profile/1",
    "id": 1,
    "name": "Mike Benson",
    "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png",
    "title": "Creative director",
    "email": "mike@buddy.works"
  },
  "project": {
    "url": "https://api.buddy.works/projects/company-website",
    "html_url": "https://app.buddy.works/buddy/company-website",
    "name": "company-website",
    "display_name": "Company Website",
    "status": "ACTIVE"
  },
  "current_date": "2016-03-11T06:54:07.428Z",
  "execution": {
    "url": "https://api.buddy.works/projects/company-website/pipelines/2/executions/1",
    "html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2/execution/56e26b8c99f1e1efed2fc65e",
    "id": 1,
    "start_date": "2016-03-11T06:54:04.728Z",
    "finish_date": "2016-03-11T06:54:06.928Z",
    "mode": "MANUAL",
    "refresh": false,
    "status": "SUCCESSFUL",
    "comment": "",
    "branch": "master",
    "creator": {
      "url": "https://app.buddy.works/buddy/member/1",
      "html_url": "https://app.buddy.works/buddy/profile/1",
      "id": 1,
      "name": "Mike Benson",
      "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png",
      "title": "Creative director",
      "email": "mike@buddy.works"
    },
    "pipeline": {
      "url": "https://api.buddy.works/projects/company-website/pipelines/2",
      "html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2/execution/56e26b8c99f1e1efed2fc65e",
      "id": 2,
      "name": "dev",
      "ref_name": "master"
    },
    "action_executions": [
      {
        "to_revision": "506a3963507943d6908154f4bc9646e829128a08",
        "status": "SUCCESSFUL",
        "progress": 100,
        "action": {
          "url": "https://api.buddy.works/projects/company-website/pipelines/2/actions/5",
          "html_url": "https://app.buddy.works/buddy/company-website/pipelines/action/5/edit",
          "id": 5,
          "name": "Upload files to dev",
          "type": "FTP",
          "trigger_time": "ON_EVERY_EXECUTION",
          "run_only_on_first_failure": false,
          "status": "SUCCESSFUL",
          "revision": null
        }
      }
    ]
  }
}

Run pipelines with slash commands

Slash commands are used to trigger things like pipeline executions directly from the Slack channel. To use the commands you must first configure an integration in Slack:

  1. Go to the target pipeline, click Slack handle and copy the URL:

    Configuring slash commands #1
    Configuring slash commands #1
  2. Go to https://my.slack.com/services/new/slash-commands

  3. Enter the name of the command and click Add Slack Command Integration. The name goes with theIn this example we'll use pipeline:

    Configuring slash commands #2
    Configuring slash commands #2
  4. Paste the URL copied from Buddy and customize the name if you wish:

  5. Click Save Integration to apply the changes

    Configuring slash commands #3
    Configuring slash commands #3

List of slash commands

This is the list of commands that you can execute from your Slack window. The [name] parameter represents the name of the command entered in the Slack integration.

  • /[name] status – displays pipeline status
  • /[name] run – runs execution
  • /[name] cancel – cancels execution (must be in progress)
  • /[name] refresh – refreshes execution
  • /[name] retry – runs execution again (must be terminated or canceled)
  • /[name] clear run – deploy and refresh can be used with the clear cache trigger
  • /[name] refresh 1c002dd – deploy and refresh can be used with any revision
  • /[name] clear run 1c002dd – clear and revision can be run together
Download Buddy Enterprise
esc

Sign up for free

No setup fees. No requirements. No obligation.

or sign up with