Run a step after every Deployment

(Brian Herbert) #1

I am using the Slack - Notify Deployment community step template to create a Slack notification when one of my projects deploys to live. This works great however I would like every single project to create a slack notification after it goes to live.

Is there a hook in Octopus which I can use to run this script whenever something is deployment to the Live Environment so that I can avoid adding the Slack - Notify Deployment step to every single project.

(Mark Siedle) #2

Hi Brian,

Thanks for getting in touch.

Yes, assuming you are using Octopus 3.5 or greater, you can use the Subscriptions feature (see the Configuration > Audit > Subscriptions menu within Octopus) and subscribe to the “Deployment succeeded” event to get notified when these events occur (you can choose to be notified by email or webhook).

We have a blog post that may help, showing how to setup a Slack notification in response to Octopus events using subscriptions. This example uses Zapier for the webhook integration, but you could roll your own webhook or use an alternative provider.

Hope this helps.

Cheers
Mark

(Brian Herbert) #3

That’s great however I have another question.

What if I have a Step Template which I would like to run when an event is fired? For example, I am using a Load Balancer to do Blue-Green deployments in Octopus. I have a Custom Step Template which will remove the Blue servers from the Load Balancer before I deploy to the Live Blue environment. Is is possible to trigger this globally instead of including the step in each project?

(Mark Siedle) #4

Hi Brian,

With the combination of Subscription webhooks and the Octopus.Client library, you could imagine a lot of possibilities for scripting various global behaviours in response to certain events. Eg. A ‘DeploymentSucceeded’ event occurs, that fires your subscription webhook, you catch the webhook and then call the Octopus API to deploy a certain project (where you’ve abstracted your step template to) … When that deployment completes, then you call the API again to trigger some other logic and so on. It doesn’t really feel like that fits for Blue-Green deployments though.

Can you tell us more about your deployment process? Why so many projects? Are they all independent (very different deployment processes) or are they all using pretty much the same deployment process but with different variables?

If you’ve got lots of projects that all share similar (but not always the same) deployment steps, perhaps you could consolidate everything into a single project that uses Channels? That way, your global step template(s) can be set to run for all channels, while other steps can be scoped to individual channels?

Cheers
Mark

(Brian Herbert) #5

We have a kind of micro-services architecture. Our environments looks like this:

  • A number websites are deployed to servers in the Web-UI role. Web-UI servers do not have access to the databases but the are on the internet.
  • A number of web API projects are deployed to servers in the API-Service role. API-Service servers access the databases but they are not on the internet.
  • The Web-UI servers have their own load balancer and so do the API-Service servers.
  • Each of the websites uses one or more web API services to access data and business logic.

We want to be able to deploy each of the websites and web API projects separately so they are in separate projects. It sounds like you are suggesting that we have one channel for the websites another for the services, managed from one project. That’s not much of an improvement over the existing version.

(Mark Siedle) #6

Hi Brian,

Thanks for the additional information.

It sounds like you are suggesting that we have one channel for the websites another for the services, managed from one project.

That’s correct. It’s one way of channelling certain parts of a deployment process that you would otherwise have separate projects for (and in this case, would allow you to share logic globally across the one project).

If this isn’t quite what you’re looking for, you could raise a uservoice suggestion explaining the behaviour you’d like to see in more detail and if it gets enough community votes it will be something we consider implementing in a future version.

Cheers
Mark

(Brian Herbert) #7

I think that Composite Step Templates would help me with this issue but it’s not ideal. I would like to have Inheritable Projects so that I could have a base project for Load Balancing which is inherited by all of my load balanced projects, not Project Hierarchy or any other suggestions.

(system) closed #9