Set-Variable and Store for Re-Deployments?

Hi All,

We’re building out a new process in Octopus that creates and verifies Service Now CM tickets. In our first step, we create a CM ticket in Service Now and set its value in the script: Set-OctopusVariable -name “CHG_Number” -value “CHG2020”.

In our email step, we output its value using: $OctopusParameters[“Octopus.Action[Set Variable].Output.CHG_Number”]

This works fine for the initial deployment. However, when a re-deployment is required, we need the first step to automatically use the CHG_Number, which essentially skips that step, as the parameters have already been entered.

This does not happen because the variable set during the deployment is not stored for future re-deployments. Is there any way to set and store a variable, which can be used in subsequent deployments? Or any other workaround that pulls a variable from the logs of a previous deployment?

We’re on Octopus 2019.3.8.

Thanks,
Alex

Hi Alex,

Thanks for getting in touch! Great question, and you’re right on the money that these output variables generated don’t get stored for re-deployments. I can think of a couple of potential ways around that, though.

You could store this in a project variable, and at the end of a deployment update the value of it and then update the release snapshot to apply the change to it. This can be done via the API and we have some sample scripts that might help.

Write the variable to a file whenever it’s changed and then call that value whenever it’s needed.

Would either of those possibilities be helpful at all?

Let me know what you think, or if you have any further questions or concerns in the future. :slight_smile:

Best regards,

Kenny

Thank you for the response, Kenneth! I will touch base with my colleague on testing out these options.

Best,
Alex

Hi Alex,

You’re very welcome! Don’t hesitate to reach out if you have any questions moving forward. :slight_smile:

Best regards,

Kenny