Only run step if the current release hasn't been previously deployed

In the documentation there is an example given of skipping a step if it has been previously run.
I want to use a slightly different approach, in which a particular step will not be performed if the currently release has already been deployed to the environment.

The run condition that looks like it should work is as follows:
#{if Octopus.Release.Number != Octopus.Release.CurrentForEnvironment.Number}true#{/if}

This however always appears to evaluate as true as the step is always performed, suggesting the variables don’t match. If I execute the below powershell as part of the same step, the variables are identical when redeploying the same release.

$b =$OctopusParameters["Octopus.Release.CurrentForEnvironment.Number"]
$a = $OctopusParameters["Octopus.Release.Number"]
write-host "Current: $a Release: $b"
$a -eq $b

I feel I’m missing something obvious here, any suggestions? :smiley:

Hi Scott,

Thanks for getting in touch! I’ve run through some tests using this run condition, and it worked just as we were expecting it to. If the last successful deployment to that environment matched the release version I was deploying (an immediate redeploy of the same release), the variable run condition evaluated to false.

Which Octopus version are you currently running?
Were any other releases deployed in between the redeploy?
Could you send us through a copy of your verbose deployment logs with debugging variables enabled? That should shed more light on what could be causing this unexpected result.

I look forward to hearing back and getting to the bottom of this one!

Best regards,


Hi Kenny,

Thanks for coming back to me and testing it on your end. Good to hear it works somewhere :smiley:
We are currently running Octopus 2018.6.12, in my current test cast no other releases were deployed in between.
I’ve attached my verbose log with the debugging variables enabled, hopefully this might shed some light? ServerTasks-45541.log.txt (28.4 KB)

Any thoughts based on the log or things I should try to resolve this one?
It’s doing my head in as it looks like it should be working. :thinking:

Hi Scott,

Seems like this thread slipped through the cracks and we totally dropped the ball. Please accept my apologies for this.

This one is definitely weird. Like Kenny said, the condition you have right now should be working.

Just for the sake of testing, could you try this equivalent condition instead?

#{unless Octopus.Release.Number == Octopus.Release.CurrentForEnvironment.Number}true#{/unless}


Hi Dalmiro, thanks for coming back to me.

Weirdly enough, that condition works :smiley:
It would be good to understand what was wrong with the other one, so I can avoid similar pitfalls in future but I am glad this is now working.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.