Blog

Repository Webhooks: Notifications for DevOps

Aug 6 2021/Platform Updates/3 min read
Webhook notifications
What are webhooks, and how do they work? Learn how to use webhooks, and how they can help expand your integrations (with example use cases!)

Webhooks, so what are they good for? Well, quite a lot as it turns out! Webhooks are great for integrating Cloudsmith with other systems that you use, by sending data or notifications to other tools in your stack and helping to enable automation across your workflows.

What is a Webhook?

I know what you’re thinking, this sounds a lot like an API right? Well, not quite. Webhooks are almost like a sibling of an API call.  So, what’s the real difference?

A webhook is what you would use to notify another system (i.e, not the same system that performed the API Call) that such an event had taken place.

When you make an API call to retrieve some information or perform an action, the API will typically check that you are authorised and then if so, perform the action or return the information you requested. A webhook, on the other hand, is a message that is pushed in response to a change or an event on a system.

How do Webhooks Work on Cloudsmith?

So, if you used the Cloudsmith API to upload a package, if you were authenticated you’d then get a response from the API confirming your action was successful.

Cloudsmith webhooks can trigger on events that occur for packages in a repository, so for example, when a package has been uploaded, is synchronizing, has synchronised or has failed.

Webhook Examples

Here are some great examples on what you can do with webhooks to help automate different workflows.

CI/CD Automation

You could use a webhook to notify your CI/CD pipeline when a new package has arrived at a Cloudsmith repository. So, for example, if you had a repository that you used for packages destined for a production environment, you could combine a webhook with repository access controls to control who was able to promote packages to production, and then use the webhook to automate the deployment process itself.

Messaging

You can use a webhook to push a notification to a chat application such as Slack or Microsoft teams when any of the supported events occur. You can customise the message to include details about the package or provide a link to it. In this way you and your teams can stay fully notified about activity on your Cloudsmith repositories without having to manually log in and check.

Monitoring & Alerting

You can use a webhook to push notifications to your monitoring and alerting platforms. You could, for example, then get notified and alerted if a specific package was deleted, and trigger further automated processes in response to your monitoring.  In this way, your monitoring platform is “aware” of activity on your Cloudsmith repository, and can take action.

Customer Contacts

If you are using Cloudsmith to distribute your packages to your own customers, you could create a webhook that notifies your mail system or CRM system that a new package has been uploaded to your repository.  You can then automate the process of informing your customers that a new or updated package is available for them to download.

But really, all this is just scratching the surface. If a component of your stack is capable of receiving HTTP POST requests and can handle a JSON or Handlebars template payload, then you can receive and process a webhook. A lot of platforms offer out-of-the-box functionality for accepting incoming webhooks, but even if yours doesn’t, you can be confident that you can put something together quickly in most cases.

Further Information & Resources

For more information, including details of the webhook payloads and a worked example, see our webhook documentation.

We've also written up another handy guide on how to configure Webhooks with Cloudsmith.

And if you make something awesome that you’d love to show off, please do let us know – we just love to see what our users can create with Cloudsmith.

Level up your DevOps, expand your integrations, and have fun building great processes with our webhooks.

Get our next blog straight to your inbox