How to skip a child step if the step above is skipped due to the package being installed?

Hi All,

I have a step in my deployment to deploy nuget package with database scripts. the child step will deploy these scripts.

I have ‘skip already installed packages’ which works as expected, however the child step will always run. I want to pair the nuget package skip with the powershell script also not running. Is there a way in the powershell script to detect if the preceeding step was skipped and if so terminate? (ideally, just not run the step at all would be great).


Thanks for reaching out. Out of the box there isn’t a way to do this. But you can manage with some conditional powershell:

  1. On your NuGet deploy step (the parent step), add the following as post deploy script:

Set-OctopusVariable -name ShouldRun -value "True"

  1. On the child step where you are invoking your database scripts, wrap your code around this conditional powershell
if($OctopusParameters["Octopus.Action[name of your deploy step].Output.ShouldRun"] -eq "True"){
    "Run my scripts"
    "Dont run anything"

make sure to update the “name of your deploy step” on the variable with the name of the parent step. For more info see this blog post to understand what we are doing here.

If on step (1) the package was already deployed, the set-OctopusVariable script will never be executed. In that case the variable ShouldRun would not exist, and the code in the else clause will be executed.

Now this is a workaround for a scenario that a good amount of users are running into. For this reason we created a uservoice suggestion to support running/skipping steps based on the value of a variable. This way you wouldnt have to use this powershell conditional workaround, and everything would be much cleaner.

If possible, please drop by the suggestion and put some votes on it if you’d like to see it implemented in future releases:

Let me know if the workaround works for you