Issue with System variables Octopus Deploy 3

Hello
We are having some issues with getting the last successful deployment of the project.
Using: $OctopusParameters[“Octopus.Deployment.PreviousSuccessful.Id”] from PowerShell doesn’t return any result.

Regards,

Patrick

Hi Patrick,

Thanks for getting in touch.

It seems that in the work for version 3.0, we neglected to set that variable. I have created an issue, and we will get it resolved as soon as possible.

In the meantime, what is the information you were attempting to retrieve from the previous deployment? We do populate the previous package version Octopus.Tentacle.PreviousInstallation.PackageVersion, and a few other related variables.

Regards,
Michael Richardson

Hi Michael,

Our ultimate goal is to get the previous release number for the current environment. This is related to this GitHub issue:

and

Damian Brady said a new variable was added however the document doesn’t mention it.

Could you please also have a quick look?

Best regards,

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify


Ahh, I see.

Octopus.Release.PreviousForEnvironment.Id and Octopus.Release.PreviousForEnvironment.Number are available. The second should give you what you are looking for.

Please let me know if this helps?
Regards,
Michael R

Hi Michael,

I use Octopus.Release.PreviousForEnvironment.Number and it works perfectly.

Thank you for your assistant.

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify


You are most welcome.

Happy deploying!

Good morning Michael,

Sorry for going back and forth with this issue.

It seems like Octopus.Release.PreviousForEnvironment.Number doesn’t give us what we are looking for.

For example,

Version 1.8.5 was in PROD on 10/08

Version 1.8.6 is current in PROD

I get 1.8.5 when using the variable. However, what I am looking for is 1.8.6 which is current version number for the current environment.

Previously I was able to retrieve it through Octopus.Deployment.PreviousSuccessful.Id.

Do you have any suggestion to get the current version number for the current environment?

Best regards,

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify


Good morning Patrick,

No problem.

I think I might have an idea what the issue is. You are deploying 1.8.6. And 1.8.6 is currently deployed?

The way we have implemented that variable is: the previous release deployed to the environment that is not the release being deployed. Which in your case is 1.8.5.

This sparked an interesting debate among our team as to what the value should be. Either value can be justified. Can we ask what you are looking to use it for?

Hi Micheal,

All we are trying to get is the version of the latest successful release for the target environment of the current deployment.

The way we used to do that is:

  • Get Octopus.Deployment.PreviousSuccessful.Id

  • Retrieve deployment information

  • Get release version

Regards,

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify


For what purpose, if you don’t mind us asking?
We’re interested in hearing some real-world use-cases.

Hi Michael,

We deploy our application nightly using the combination of TeamCity and Octopus Deploy. There is one step in our Octpus Deploy process that checks the current version of the application and stops the deployment if we are trying to deploy the same version.

Best regards,

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify


Hi Patrick,

We’ve decided to leave Octopus.Release.PreviousForEnvironment.Number working the way it currently is. Both because customers may depend on it’s current implementation, but also because it can certainly be argued that it is correct.

So, what we’ll do is create some new variables:
Octopus.Release.CurrentForEnvironment.Number
Octopus.Release.CurrentForEnvironment.Id

I’ve created a ticket for this.

In the meantime, you can possibly get the information you want via the Octopus REST API.

Don’t hesitate to let us know if we can assist further.

Regards,
Michael

Thanks Michael for your support.

Patrick


Patrick Dinh | Readify Developer | m +61 400 680 058 | e patrick.dinh@readify.netmailto:firstname.lastname@readify.net | w readify.nethttp://www.readify.net/links/readify