Stash Plugin Tutorial: Beer O'Clock Repository Hook

January 8th 2015 Tim Pettersen in Git, Stash

One of my favorite Stash features is its plugin system. Since Stash is a git repository host, 99% of Stash users are software developers. And since developers often like to scratch their own itch, we've invested heavily in extensibility and customization to make plugins both powerful and simple to write. In this 30 minute video tutorial, I'll walk you through building, deploying and debugging a simple repository hook plugin, from scratch.

A plugin is an executable bundle of code that provides additional functionality to your Stash server. It does this by consuming services from the Stash API and implementing plugin points provided by the Stash SPI. There are many plugin points to choose from, allowing you to build your own features with custom UIs, REST APIs, pull request merge checks and repository hooks, among other things. The logic of this plugin is written in Java, but the actual amount of code is tiny, so you should be able to follow along even if you have little or no Java experience.

Make sure you view the video in HD mode (at least 1080p) so you can read the text.

If you're already done some Stash plugin development, you might want to skip ahead to a specific part of the video to learn more about a particular topic. This tutorial covers:

  • auto-generating a new Stash plugin (2:32) and different types of plugin modules (8:20) using the Atlassian SDK
  • flushing messages to the developer's console when they push changes to the repository (12:22)
  • spinning up a personal Stash server in developer mode using atlas-debug (14:52)
  • what an Atlassian "timebomb" license is (20:49)
  • attaching a debugger to Stash to step through plugin code with breakpoints (24:19)
  • hot deploying plugins to Stash using atlas-cli (26:21) for rapid iterative development
  • me implementing, then fixing, a nasty bug. If you're game, watch from the beginning and see if you can catch it before I do :)
Hook code Hooks screen Pushing

If you enjoyed the video, have questions or want to see a tutorial on a specific aspect of plugin development, drop me a line on Twitter (I'm @kannonboy).