Release Variable Snapshot Json Query

Hey guys.

I have a query with regards to the Release Variable Snapshot returned by the REST API.

  1. I have a project that has many releases created.
  2. I used the REST API to get release snapshot info of an old release.
  3. I used the REST API to get variable snapshot info from the returned JSON from step 2.
  4. The API returned me all variable info as well as all the scopes like environments, actions etc.
  5. The one issue I’m having is one of the variable that is scoped to an action, when I try to look up the referenced actionId with the returned action scope list I can’t find any matches by Id but I can find a match by name.

It’s like as if the included scopes list returned by the API is not the snapshot version?

Hi Alan,

Thanks for getting in touch!

I’ve run a test of the scenario that I believe you’re running, and I am seeing the action ID matching within the JSON.
These are the steps I’ve taken:

  • Create a new project variable
  • Scope the variable to step 1. Health Check
  • Create a new release
  • Retrieve the release variable snapshot (/api/Spaces-23/variables/variableset-Projects-181-s-1-4PXD9)
  • The Action ID (b3f7b162-6c72-4645-b960-3dd04732e658) in the variable scope matches the Action ID within the Actions section
{
  "Id": "variableset-Projects-181-s-1-4PXD9",
  "OwnerId": "Projects-181",
  "Version": 1,
  "Variables": [
    {
      "Id": "3d387525-9365-ca50-b767-fa7dc7141c9f",
      "Name": "newvariable",
      "Value": "new",
      "Description": null,
      "Scope": {
        "Action": [
          "b3f7b162-6c72-4645-b960-3dd04732e658"
        ]
      },
      "IsEditable": false,
      "Prompt": null,
      "Type": "String",
      "IsSensitive": false
    }
  ],
  "ScopeValues": {
    "Environments": [
      {
        "Id": "Environments-61",
        "Name": "Dev"
      },
      {
        "Id": "Environments-101",
        "Name": "Prod"
      }
    ],
    "Machines": [
      {
        "Id": "Machines-321",
        "Name": "Azure Web App"
      },
      {
        "Id": "Machines-241",
        "Name": "AzureSSH"
      },
      {
        "Id": "Machines-341",
        "Name": "Offline"
      },
      {
        "Id": "Machines-301",
        "Name": "PAULLAPTOP"
      },
      {
        "Id": "Machines-141",
        "Name": "paultest"
      },
      {
        "Id": "Machines-161",
        "Name": "SF Test"
      },
      {
        "Id": "Machines-282",
        "Name": "SFCluster"
      }
    ],
    "Actions": [
      {
        "Id": "b3f7b162-6c72-4645-b960-3dd04732e658",
        "Name": "1. Health Check"
      },

Am I looking in the same place as you, or have I missed a step somewhere?
If the steps I took are correct and you are seeing something different, what version of Octopus are you running?
This was tested on 2020.4.0 so it could be a version issue.

Regards,
Paul

HI Paul

Thanks for the swift respond.

The issue I am having seems to only occur when querying an older release.

For e.g. you have created 5 release and have probably altered some stuff before each release creation.

You then go and query the 1st release snapshot created thats where the issue happens where the variable that is scoped to an action, you cannot find the matching actionId from the action scope values.

E.G.

Here’s the variable that has action scope

{
        "Id": "6f5e1e1f-e9d8-4609-83e2-a82425b8d721",
        "Name": "MarketLobbyDesc",
        "Value": "UnitedKingdom:*",
        "Description": null,
        "Scope": {
            "Action": [
                "cb389922-1eb5-44cc-b7e3-e7cbb3781695"
            ]
        },
        "IsEditable": false,
        "Prompt": null,
        "Type": "String",
        "IsSensitive": false
    },

From looking at the action list from the ScopeValues object the matching action should be this one

 {

     "Id": "b1edf7b8-2bad-4903-85e9-5031c4f3a1af",

     "Name": "18. Deploy Database United Kingdom UK"

 },

However you can see the actionId don’t match.

I then had a look at the same release deploymentsnapshoptId and I can see the matching actionId

{

            "Id": "39d96c91-8dab-47a2-a874-84266e81f577",

            "Name": "Deploy Database United Kingdom UK",

            "PackageRequirement": "LetOctopusDecide",

            "Properties": {

                "Octopus.Action.TargetRoles": "System.Database.PlayNext.Games"

            },

            "Condition": "Success",

            "StartTrigger": "StartAfterPrevious",

            "Actions": [

                {

                    "Id": "cb389922-1eb5-44cc-b7e3-e7cbb3781695",

                    "Name": "Deploy Database United Kingdom UK",

                    "ActionType": "Octopus.TentaclePackage",

                    "IsDisabled": false,

                    "CanBeUsedForProjectVersioning": true,

                    "IsRequired": false,

                    "WorkerPoolId": null,

                    "WorkerPoolVariable": null,

                    "Environments": [

                        "Environments-601"

                    ],
           ...

We are using octopus version 2020.1.17

Within those last 5 releases, is it possible that the process step has been cloned, the original one deleted, and the new cloned one renamed to the original name?

That is the only scenario where I’ve been able to replicate this behaviour. The Action ID of the step doesn’t change no matter what changes I make to the step itself. However, performing a clone and switching it all around does result in the variable snapshot having the wrong action ID for the step.
e.g.

    {
      "Id": "be55d056-d1f1-d302-be95-0a3ce9bb05c8",
      "Name": "ConnectionStrings:DefaultConnection",
      "Value": "User ID=#{DB.UserId};Password=#{DB.Password};Data Source=#{DB.DataSource};",
      "Description": null,
      "Scope": {
        "Action": [
          "278a53f0-35a9-4c06-8e3e-a71f5d23c72e"
        ]
      },
      {
        "Id": "f74c8bde-aa93-433a-83be-5ab051fa6826",
        "Name": "2. webconfig1"
      },

It does seem that the variable snapshot is pulling live data in regards to the Actions section. I’m honestly not sure if this is intended or not, it feels wrong but there may be some logic behind it.
I’m going to discuss this internally and see what we come up with.

Regards,
Paul

Thank you so much.

Please do let me know as we have hosted multiple instances of OctopusDeploy and sometimes we need to “promote”(clone/copy) a release from one instance to another which involves updating project settings, deployment steps etc before creating the release itself on the target instance.

For now we have only been doing it on newly created releases and not older releases hence only found out about this now.

Hi Alan,

I’ve checked on this and it seems that the additional sections in the variable snapshot (Actions, Roles, Channels etc) are what the UI uses to generate the possible scope options for a variable on the Variables page. This is why it will always update to match the current live information.

The data in these sections isn’t used during the actual deployment at all.

Regards,
Paul

Thanks for clarifying this Paul.

1 Like

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