System Variables - Get release using project

(Clayton Taylor) #1

Is there a way to get a specific Octopus.Release using Octopus.Project.Name/Id for the current environment using system variables? I know I can do this via the Octopus REST API, but it would make step templates far simpler if this could be passed as a parameter.

(Michael Richardson) #3

Hi Clayton,

Apologies for the late reply.

No, the variables don’t contain values for past releases. Would you be willing to share a little more about your scenario? Perhaps there’s something we can do better, or another way to approach it?

(Clayton Taylor) #4

Hey

Thanks for getting back, I didn’t know if I had used the right channel to ask about this. What I would like to do is get the current Release in the current Environment using a Project.Name or Project.Id via Octopus system variables. This would allow me to do several things specific to a particular release from other contexts.

For example, if you could pass Project.Id to a Release then you might be able to do something like “#{Octopus.Release[#{Octopus.Project.Id}].CurrentForEnvironment.Id}”. Doesn’t need to be that syntax specifically, but hopefully that helps illustrate what I’d like to do.

(Michael Richardson) #5

There are the following variables:

  • Octopus.Release.PreviousForEnvironment.Id
  • Octopus.Release.PreviousForEnvironment.Number
  • Octopus.Release.CurrentForEnvironment.Id
  • Octopus.Release.CurrentForEnvironment.Number

which will always be populated for the currently executing project. See our docs for more details.
There is no need to pass the project ID if it is the project being deployed that you are interested in.

If it is not the current project you are looking for, then unfortunately there are no built-in variables which will help. You will need to call the Octopus HTTP API for those.

Is it the project being deployed you are looking for the previous release details of?

(Clayton Taylor) #6

No, I am trying to access it from another project. I had a feeling that I need to write a script to accomplish this instead.

I am using the “master project” philosophy to coordinate releases for a series of microservices, so something like this would be useful for multiple step templates. Is there any chance something might get added to the system variables for this?

(Michael Richardson) #7

Have you seen the Deploy a Release step? It was designed to help with this scenario.

Would this fit for you?

(Clayton Taylor) #8

That’s exactly what I am doing actually. I have several steps after deployment that will rely specifically on the package version currently deployed to the current environment, but in some cases the package will not be deployed by the current release. That’s why I need to get a release by using the current environment and a project.