Automation Using Webhooks in JFrog Artifactory

Artifactory and Webhooks

You (probably) already know that Artifactory, as your repository manager, plays a vital role in your CI/CD pipeline by bridging the gap between development and operations. Now, we’re giving you the option to use webhooks with Artifactory to automate your processes even further. Read on…

First, what are webhooks?

In the most simple terms, a webhook is an automated notification mechanism that is triggered by events that you define based on your priorities. When a webhook is triggered, it sends relevant information about the event to a web location that is listening for that specific event notification (I’ll give an example in a second). As such, the webhook is comprised of three simple components – the triggering event, the information about the event (the “payload”), and the web location listening for the event.

For a simple example, let’s say you’re part of Team A, and you’ve completed a new Docker tag in Artifactory (this is the “event”). Well of course, Team B needs that information (the “payload”) about that tag for their new build. With webhooks and Artifactory, you can configure an automatic notification to Team B’s build server (the location listening for the event) as soon as that component is available, triggering a build for Team B automatically that includes this new information. Now, there’s no need for manual, human interaction between teams for this particular task.

Can’t I wait for source code commit changes?

You certainly can, and that’s one way to achieve the same goal. You could also use the same build server for both teams to avoid any missteps. But that’s not always possible in reality, as different teams may use different build servers, different source control servers and are often separated geographically. This is where Artifactory (with webhooks!) comes in, as the source of dependencies and the destination for finished components across teams.

Working with the Artifactory webhook plugin

You’re probably ready to start playing with webhooks in Artifactory. It’s simple with an easy plugin.

You can find the webhook plugin, along with other great community driven, JFrog-maintained user plugins on our public Github. The webhook plugin allows for a large number of configuration options out of the box, including listening to multiple events (such as a new Docker tag being created), filtering for specific repositories and specifying the package format. This can all be done with a simple, easy-to-read configuration file. If you’re willing to get your hands a little dirty with Groovy code, you can customize it even further, creating your own formatters or adding more events that can trigger the webhook.

Installing the plugin is also a breeze, simply drop the plugin into your Artifactory’s plugin directory, add the configuration to specify what events want to trigger a webhook and you’re all set.

Pro tip: there’s no need to restart Artifactory. Use the reload plugins API call.

Bonus: Webhooks are for humans too

Webhooks aren’t just a great way to help you automate parts of your CI/CD. They can be quite helpful to us humans as well. You can, for example, set up a webhook that notifies your developers’ Slack channel that a new build has just been published. You can use it to alert you if files from a protected repository have been deleted or modified. You can adopt it for a myriad of other helpful tasks – webhooks just plain make things easier.