Step Variable Run Condition only when previous steps succeed

pnolan's Avatar

pnolan

31 Dec, 2017 05:26 AM

Hi,

Is there a way to use a Step Variable Run Condition, however, also only run the step when previous steps have succeeded?

  1. Support Staff 1 Posted by Kenneth Bates on 02 Jan, 2018 12:22 AM

    Kenneth Bates's Avatar

    Hi,

    Thanks for getting in touch! While there's no built-in functionality to allow multiple run conditions like this (only one option can be selected at a time), you can still work around this using nested #{if} conditions within the variable expression condition to depend on multiple conditions.

    You can take advantage of the system variable Octopus.Step[StepName].Status.Code and only run when the value equals Succeeded for the single step. This is a workaround, as it depends on only the single step you define, but you could set the condition of that defined step to Success: Only run when the previous steps succeed and you could get the same behavior that way.

    Specifically, I was able to get this working using something a variable expression like this:

    #{if Octopus.Step[StepName].Status.Code == "Succeeded"}#{if variable2 == "true"}true#{/if}#{/if}

    Let me know if this helps, and don't hesitate to reach out if you have any further questions. :)

    Best regards,

    Kenny

  2. pnolan closed this discussion on 03 Jan, 2018 11:19 AM.

  3. pnolan re-opened this discussion on 09 Jan, 2018 02:47 AM

  4. 2 Posted by pnolan on 09 Jan, 2018 02:47 AM

    pnolan's Avatar

    Although Kenneth got me on the right path it didn't seem to work. With some extra searching I found a better solution here

    https://octopus.com/blog/deployment-process-uservoice-update

    To run a step only if all previous steps were successful, and based on the truthy value of a variable:
    #{unless Octopus.Deployment.Error}#{VariableToCheck}#{/unless}

  5. Support Staff 3 Posted by Kenneth Bates on 09 Jan, 2018 04:18 AM

    Kenneth Bates's Avatar

    Hi,

    Thanks for following up! I'm sorry my previously mentioned solution didn't work, but it's great to hear you have an even better one. Thanks for taking the time to let me know. :)

    Don't hesitate to reach out if you have any further questions going forward.

    Best regards,

    Kenny

  6. pnolan closed this discussion on 11 Jan, 2018 11:30 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac