Run Condition always evaluates to "false"

I am trying to use a variable condition to decide whether or not to run a step, but I can’t seem to get it to work.

We are running Octopus Server version v2019.9.7 LTS.

In my case, I only want to run a step if the release name equals ‘develop’ after all non-alpha characters have been removed. To do this, I’m using the Replace filter, and I have tested the following expression in a script and it works as expected - #{Octopus.Release.Number | Replace "[^a-z]"}.

Examples -

1.2.3-some-branch    >> somebranch
3.2.1-another-branch >> anotherbranch
1.1.1-develop        >> develop
1.4.27               >> 

In my run condition, I have tried many different statements, but they all evaluate to false.

#{Octopus.Release.Number | Replace "[^a-z]" == "develop"}
#{Octopus.Release.Number | Replace "[^a-z]"} == "develop"
#{if Octopus.Release.Number | Replace "[^a-z]" == "develop"}True#{/if}
#{if Octopus.Release.Number | Replace "[^a-z]" == "develop"}true#{/if}
#{if Octopus.Release.Number | Replace "[^a-z]" == "develop"}

Sadly the documentation for run conditions is a little be lacking, and I’m not really sure why this is not working?


Hi David,

Thanks for getting in touch!

It does seem like this should be working, my best guess as to why it isn’t would be that for some reason the Replace isn’t being run within the run conditional.

I’m going to check this with our engineers for clarification.

Another way to achieve this though would be to use an output variable in an earlier step and then perform the run condition check on that variable.

Step 1 - Check Script
Set-OctopusVariable -name “RunCheck” -value “develop”

Then place this in the step that you need to perform the run condition check, the [Check Script] part would be whatever you use for the name of the step above.
#{if Octopus.Action[Check Script].Output.version == “develop”}true#{/if}


Hi Paul,

Thanks for your response.

In my case it’s probably better to add a check to the script that I wish to conditionally run, rather than adding a whole new script and then referencing an output from it in the run condition of my existing script.

However, both ways are pretty dirty and I’d prefer to use a run condition without additional scripting, so hopefully your engineers will be able to provide some good news.


Hi David,

A slightly cleaner option would be to use a project variable rather than an output variable.

Set up a project variable SanitisedReleaseNumber with value #{Octopus.Release.Number | Replace "[^a-z]"} and change the condition to #{if SanitisedReleaseNumber == "develop"}true#{/if}


Hi Paul,

Thanks, that’ll do the job for now. So can I assume that the Replace filter (maybe all filters?) does not work on run conditions?

By the way, we have Octopus Server version v2019.9.7 LTS.


That does seem to be the case, it looks like the parsing is too difficult for the run condition to process.