Octopus system variable for release number of another environment

I want to fail my production deployment if the version I’m deploying to production does not match the version currently in my staging environment. Essentially I want to do something like:

If (Staging.Octopus.Release.Number -ne Octopus.Release.Number){
Write-Error “Deployment failed since release is not the current staging release”
}

The rest of my deployment

Is that possible?

(I want this because my production deployment logic always deploys the current staging environment, so if a user tried to deploy a release that is not currently in staging they will always end up deploying the version in staging anyway - which could lead to some odd human error.)

Essentially I want to enforce workflow :stuck_out_tongue:

Oh - and in case it isn’t obvious I’m doing this in PowerShell, if it makes any difference.

Hi Alex,

On 2.6 pre-release we added Lifecycles which seems exactly what you want to do. This way the “deploy to production” option wont appear if it wasnt previously deployed to Staging. Have you checked our post on the new2.6 features? https://octopusdeploy.com/blog/2.6

We’ll have documentation specifically for Lifecycles on the upcoming days. In the meantime, feel free to try out 2.6 pre-release. You can get it from here: https://octopusdeploy.com/downloads/2.6.0

Thanks!

Dalmiro

Thanks for your email.

I’m on annual leave until Thursday. If you need help before then please contact tom.austin@red-gate.com.

I apologise for the inconvenience.

Alex Yates
Intl Tel: +44 (0)1223 438 709
US Tel: 1-877-745-2608
alex.yates@red-gate.commailto:alex.yates@red-gate.com
www.workingwithdevs.com

Sorry it took me so long to reply. Unfortunately I didn’t get the time to look into this before but I just read the post and I think the ‘Phases’ feature of lifecycles is exactly what I want.

Thanks Dalmiro - this lifecycles feature does look pretty impressive. :slight_smile: