Octopus version variable?

Is there an Octopus system variable which returns the version number of Octopus Deploy?
e.g. {#Octopus.Version} or {#Octopus.Version.Major} {#Octopus.Version.Minor} {#Octopus.Version.Build} {#Octopus.Version.Revision}

Regards,

Rich

Hi Rich,

Thanks for reaching out! By “Version Number of Octopus Deploy” you mean the version of your Octopus Deploy server? If that is not the case, let me know. If that IS the case, can you let me know where are you trying to use this? There’s not a variable for it, but depending on the context where you want to use it there might be different ways to get it.

Also please let me know which version of the Octopus Server you are running.

Thanks!
Dalmiro

Dalmiro ,

Yes, I it is the version of Octopus Deploy server I am after
I want to use it in an email template as described in: http://docs.octopusdeploy.com/display/OD/Email+notifications

I am using 3.3.26

Regards,

Rich

Hi Rich,

So sorry for the delay in responding! You can definitely include the server version in your email through a couple of steps:

  1. In a PowerShell step, get the Octopus server info and send it to an output variable. Here’s a code snippet that does exactly that:
##CONFIG##
$OctopusAPIkey = "" #Your Octopus API Key
$OctopusURL = "" #Your Octopus Server root URL

##PROCESS##
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$ServerVersion = ((Invoke-WebRequest $OctopusURL/api -Method GET -Headers $header).content | ConvertFrom-Json).version
$ServerVersion
  1. Use that output variable in your Email step. Here’s some example code you can use as a template for your email:
    <p>Server Version = #{Octopus.Action[PowerShellStepName].Output.ServerVersion}</p>

There’s also a great blog post about output variables if you’re interested!

I hope that helps!

Kenny

Hi Rich,

I want to fix a mistake with the copy/paste of code I sent earlier (left out a line). Sorry about that! In the PowerShell script step, use this instead:

##CONFIG##
$OctopusAPIkey = "" #Your Octopus API Key
$OctopusURL = "" #Your Octopus Server root URL

##PROCESS##
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$ServerVersion = ((Invoke-WebRequest $OctopusURL/api -Method GET -Headers $header -UseBasicParsing).content | ConvertFrom-Json).version
$ServerVersion

Set-OctopusVariable -name "ServerVersion" -value $ServerVersion

Kind regards,

Kenny

Thank you Kenny.

There is a typo in your code. When you convert from JSON, which is case sensitive, the .version should be .Version (capital V)

I do however, wonder why there is not a less convoluted way of achieving this. Why can we not have a system variable e.g.#{Octopus.Version} which would then avoid an unnecessary web request.

Regards,

Rich

Hi Rich,

Version is a property of a PSObject at that point in the code, hence it shouldn’t be case sensitive. I’ve tested this with Lowercase and Uppercase “v” and it worked in both cases (see attached screenshot)

To be honest we haven’t been asked too much for a variable with such info, and that’s pretty much the single reason why we haven’t implemented it. I’ll bring that idea to the team and see what we can do about it.

The idea of this Powershell approach was just to get you up and running right away :slight_smile:

Best regards,
Dalmiro

Forgot to attach the screenshot!

Thanks very much for your help. It has partially solved my problem. Just trying to plan how to integrate into our existing projects. Of course would very much welcome the system variable.

Part of the reason I need it is that I’m in the Development Team and the responsibility for Octopus Server will be handed over to Infrastructure Team soon. I need to know what version of the software we are running so I can plan deployments and know what features are available. This variable will become very important when we start to deploy worldwide from our parent company.

Was unaware of the case insensitivity of the object, thanks. It did not work for me until I changed it to uppercase. However, I was changing many things so could have been something else. Apologies.

Regards,

Rich

Hi Rich,

At the moment our Features team is a bit swamped after the release of 3.4 a couple of weeks ago, so I cannot slip in new enhancements like this one so easily (I did try though). I’ve created a Uservoice Suggestion for this as an easy way to track how many users would like this idea to be implemented. If you can drop by and add some votes to it, It’ll definitely help your cause: https://octopusdeploy.uservoice.com/forums/170787-general/suggestions/16099462-octopus-variable-to-get-current-version-of-octopus

For the time being, that Powershell+API approach is the only feasible way I’m afraid.

Best regards,
Dalmiro

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.