Variable Preview API - Release Snapshot

Currently, the REST API allows for passing in the following for variable previews:
Currently, though, I don’t see a single way to handle a release’s snapshot. While I understand you can query the variables in a snapshot, there doesn’t appear to be a way to get all variables in the snapshot. Instead, there’s the project snapshot and the individual snapshots for each library variable set.

Is there any way to handle querying a release for it’s evaluated variables? We have a need to validate the configuration for all environments for a given release. Is that doable? If not, is it possible to add this feature, or to add passing in a release to the variable preview?

As an additional note, I spent the last two days getting somewhat reliable script going to query the project snapshot from a release, as well as all variable set snapshots, exclude those not set to current scopes, and retrieve values. The one area it is severely lacking is the variable specificity. For example:

  • Db.Name – ProductA_Alpha – Scoped to DEV
  • Db.Name – ProductA_Beta – Scoped to TEST
  • Db.Name – ProductA – Unscoped

It’s currently hard to tell when to load which variable. It’s easy enough to skip out on variables scoped to environments that are not the current one, but much harder to determine that I should ignore the unscoped variable when pulling the variable in TEST.

Is there a library that I can use that has Octopus’s variable specificity available? If possible, I’d like to essentially pass in an array of [Octopus.Client.Model.VariableResource] and a set of Scopes, and then it should return an evaluated set. I don’t want to try and re-create the wheel here myself, as there’s no guarantee that what I do will be the same as what Octopus will do at deployment time.

Hi Chris,

Thanks for getting in touch! I’m sorry for the delay in responding here.

First, I will note that our Octopus.Clients API repository is completely open source. It contains the following file ScopeSpecifications which contains the logic used to set variable specificity. This may help you with your custom script you are making.

As for adding the ability to see all evaluated variables from the release snapshot, this is not currently possible in Octopus. I believe the best thing to do would make this request over on our UserVoice suggestions page. You are able to create suggestions and vote/comment on other ideas you would like to see in Octopus.

Let me know if the scope specifications file is what you were after here. If you have any other questions at all, please don’t hesitate to let me know.

Best regards,

Hey Daniel,

I completely missed Rank(), so thank you greatly for pointing that out. The only issue I’ve found is that when calling it for an unscoped variable from a ProjectVariableSetSnapshot it returns a value of 0. I would expect it to only be 0 from an unscoped variable in a LibraryVariableSetSnapshot, whereas a project variable should be 1.

score += Score(ScopeField.Project,      1);

Am I doing something incorrectly? None of the variables queried from the ProjectVariableSetSnapshot return with a project-level scope, so I wasn’t sure if that was a bug on the Octopus end or just a misunderstanding on my part.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.