Is it possible to execute script from each deployment step package before/after executing any deployment steps


I have a project with following steps:

  1. Update database
  2. Deploy web application
  3. Deploy windows service

I would like to have a way to execute script(s) from each nuget package configured for steps 1-3, before any of the steps get executed.
Assuming I have the standard Deploy.ps1 and PreDeploymentProcess.ps1 in nuget packages for each step. I wasn’t able to find this funtionality. Is this possible in any way (other than creating additional steps). I assume it’s not so my suggested solution would be:

I would like Octopus deploy to create “virtual steps” like Update database (pre deployment process), Deploy web application (pre deployment process) and Deploy windows service (pre deployment process) which all execute just the PreDeploymentProcess.ps1. Then regular steps would execute Deploy.ps1 as usual and then another set of virtual steps would be created after all deployment steps were executed.

This is essentially the same functionality as PreDeploy.ps1 but for the whole deployment process instead of for a single step.
Each of the virtual steps should have exact same scope as the actual step it has been created for so that variables scoped to Update database step would be available in both Update database (pre deployment process) and Update database (post deployment process) steps.

The reason why I would like to do this is to stop all web applications / services before attempting to update the database.

I know I can add explicit steps before Database update to stop services but the idea is to limit the configuration to the minimum. Otherwise in this simple scenario I would nee two additional steps and then I would need to manage variable scoping for those. We have projects where we release up to 8 services and adding additional 8 steps will be a little of a hassle compared to adding PreDeploymentProcess.ps1 to our nuget.

Is this something that you would consider adding to Octopus Deploy or should I get used to having to add additional steps for every actual deployment step I have?

Hi Robert,

Thanks for getting in touch! The name of the files should be PreDeploy.ps1 and PostDeploy.ps1

Please check this link for better reference on how to add these scripts to your solution so they get packed properly

Let me know if that helps


@Dalmiro the link is not working. Thanks Alex

Hi Alexandre,
Is this closer to what you are after?

Let me know if you need further clarification.
I hope that gets you going with your deployments.