DEV Community 👩‍💻👨‍💻

Cover image for Trigger an Octopus Deploy Runbook using an Elgato Stream deck!
Sarah Lean 🏴󠁧󠁢
Sarah Lean 🏴󠁧󠁢

Posted on • Originally published at techielass.com

Trigger an Octopus Deploy Runbook using an Elgato Stream deck!

Automation and things that mean a few button clicks less are always a winner (in the right circumstance). In this blog post I want to share how I am using the Octopus Deploy REST API and my Elgato Stream deck to trigger an Octopus Runbook!

Octopus REST API

Octopus Deploy is built REST API first, meaning everything you see within the Octopus Deploy portal is built on top of that API.

Which again means you can start to perform operations using the REST API. In this instance I'm going to be using a PowerShell script to query the REST API to publish an Octopus Runbook and then run it. More on that later. 😉

Elgato Stream deck

If you haven't heard of the Elgato Stream deck, it can be a hardware device or mobile app that allows you be able to perform an action at the press of a button.

Elgato Streamdeck

I have mine setup to do things like turn on and off my office lights, which are Phillips Hue and Elgato lights. I've also go buttons that can mute my microphone when in a Zoom call and I have buttons configured to changes scenes within OBS.

There are all sorts of things you can use the buttons for.

Trigger an Octopus Runbook from a script

I wanted a way of being able to keep of a couple of runbooks I have without actually having to log into the Octopus Deploy portal so I had a look a the Octopus Deploy REST API documentation and found a couple of great examples of for doing this.

The first is to publish your Runbook.

A runbook within Octopus has the status of either draft or published. A draft is as you'd expect, a work in progress and might not be approved for production use.

A published runbook is one that is approved for use and ready for use. You need to publish your runbook before you can trigger it through the REST API or the Octopus CLI tool.

So we a published runbook, we now need to run it.

There is also an example of how to do that within the Octopus Documentation.

But that's a separate script and I wanted to have the whole process in one script that could be ran easily....

So I took some of the bits from the run script and pieced it together into one script that now publishes the runbook and then runs it.

You can find my complete PowerShell script here: https://gist.github.com/weeyin83/b68381317e6923343f195f6b0e514b21

Trigger an Octopus Runbook from my Elgato Stream deck

The thing with scripts though, you can never find them when you want them. So I wanted even quicker way to trick the scripts and runbook. Then I realised I could actually run that PowerShell script from my Elgato Stream deck!!

Opening the Stream deck software I searched for the System > Open key configuration and dragged it over to a free key.

I gave the key a title that made sense. In this case "Getting Started Runbook Create".

And then in the App/File section I wrote:

pwsh.exe -executionpolicy bypass -file "C:\triggercreateinfra.ps1"
Enter fullscreen mode Exit fullscreen mode

Elgato configuration

Whenever I press that key on my Elgato Stream deck it runs the PowerShell script and kicks off my runbook. This is a runbook I often have to run before a demo so it's great being able to kick it off easily ahead of the demo. 👍

Let me know what other great things you've done with your Elgato Stream deck!

Oldest comments (0)

🌚 Life is too short to browse without dark mode