Is there a way to check if a step was skipped during deployment in Octopus Deploy?

(Adam Close) #1

In my process, I have a number of deploy package steps that also run custom scripts. Some of the scripts should only partially run if other steps in the process were skipped. Is there a way of checking if any steps in my process were skipped?

(Adam Close) #2

This can be achieved using Octopus system variables. Octopus provides variables to track deployment and the status of each step, and this will help us check if a step was skipped.

Let’s say I have a process with three steps, the third step deploys a package and runs a custom PS script post-deployment, but I only want the script to partially run if step 1 wasn’t skipped.

I’m going to use Octopus.Action[A].IsSkipped variable to check if the step was skipped.

Write-Host 'Running Custom Script'

$IsStepSkipped = $OctopusParameters["Octopus.Action[Step-1].IsSkipped"]

if ($IsStepSkipped -ne "True"){

Write-Host 'Step was not skipped, so do some more work...'


If Step-1 wasn’t skipped, then $IsStepSkipped would return a blank value, but if it is, then it will return true.

You could also include $OctopusParameters["Octopus.Action[Step-1].IsSkipped"] in your project variables and use run condtions to evaluate the value.