The Cloudsmith Developer Hub

Welcome to the Cloudsmith Developer Hub. You'll find comprehensive guides and documentation to help you start working with Cloudsmith as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Slack

How to integrate Slack with Cloudsmith

This guide shows you how to post a message like an example below to a Slack channel every time a package is successfully uploaded.

Slack message from Cloudsmith after a Python package synchronises

Prerequisites: you need a paid Cloudsmith account, a repository where you are an admin and access to a Slack Workspace

Configure Incoming Webhooks on Slack

  1. Create a Slack App on their site, in this example we called ours Cloudsmith.io
  2. On the next page, near the bottom, add a short description, add an icon choose a colour, we picked a Cloudsmith Icon and #333333 and 'Save Changes'
  3. Choose 'Incoming Webhooks', back towards the top, and on that page: 'Activate Incoming Webhooks' then 'Add New Webhook to Workspace'; choose a channel and then 'Authorize'
  4. Test the webhook with the curl command
  5. Copy the webhook URL, which looks like https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX, to use below

After creating your app you can view its settings at https://api.slack.com/apps.

Create Webhook on Cloudsmith

  1. Open your repository in Cloudsmith and browse to the 'Webhooks' page using the menu on the left
  2. Choose to 'Create Webhook'
  3. Add the webhook URL from above to the box labelled 'Target Endpoint URL'
  4. Choose 'Handlebars Template' as the 'Payload Format'
  5. Select 'Package Synchronised' from the row of events
  6. Add your handlebars code; the template below produced the message shown above
  7. Under 'Webhook Event Subscriptions' select 'Send Specific Events (choose)' then check 'Package Synchronised'
  8. 'Create Webhook'
{
  "text": "New package from _{{ data.uploader }}_",
  "attachments": [
    {
      "fallback": "{{ data.filename }} version {{ data.version }} by {{ data.uploader }}",
      "text": "{{ data.summary }}",
      "title": "{{ data.filename }}",
      "title_link": "https://cloudsmith.io/user/login/?next=/package/ns/{{ data.namespace }}/repos/{{ data.repository }}/packages/detail/{{ data.slug }}",
      "mrkdwn_in": ["fields"],
      "color": "good",
      "fields": [
        {
          "title": "Repository",
          "value": "{{ data.repository }}",
          "short": true
        },
        {
          "title": "Version",
          "value": "{{ data.version }}",
          "short": true
        },
        {
          "title": "Description",
          "value": "{{ data.description }}",
          "short": false
        }
      ]
    }
  ]
}

Upload a package and enjoy the awesome automated Slack posts!

📘

Webhook Event Types

For more information about the events triggered by the package synchronization process please see here

References

This guide is based up Slack's own documentation. Slack also has documentation about message formatting and the Slack message builder shows what a message will look like.

Cloudsmith Icon

Using ImageMagick we created an icon to matching both Slack's guidelines and Cloudsmith's branding page :

curl -O https://corp.cloudsmith.io/assets/cloudsmith-icon-master-color.svg
convert -resize 800x800 cloudsmith-icon-master-color.svg 800x800.png

Updated 3 months ago


Slack


How to integrate Slack with Cloudsmith

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.