Missing Resource when adding Environment to scope

Hi,
I am adding a new Library Variable Set via a powershell script and I am seeing the following error when I add an Environment to the scope:
It adds the Environment no problem when I add it manually. Any idea why this would be happening??

$variable1.Scope.Add([Octopus.Client.Model.ScopeField]::Environment, (New-Object Octopus.Client.Model.ScopeValue(“Environment Name”)))

image

Thanks,
Mike

Hi Mike,

Thanks for getting in touch!

I’m wondering if it is somehow retrieving the wrong environment-id when adding the scope.

After running your script to add the variable, if you also manually add a value with environment scope so that the variable has a mix of both working and not working values.

Then retrieve the variable set using <octopusURL>/api/Spaces-1/variables/variableset-Projects-21
You’ll need to replace the project ID at the end, you can retrieve this using <octopusURL>/api/Spaces-1/projects

You’ll then be able to compare the environment IDs assigned to the values.
e.g.

{
      "Id": "82ddf300-4d3e-84c2-2d05-ac56d43439c1",
      "Name": "TestVariable",
      "Value": "Test1",
      "Description": null,
      "Scope": {
        "Environment": [
          "Environments-1"
        ]
      },
      "IsEditable": true,
      "Prompt": null,
      "Type": "String",
      "IsSensitive": false
    },
    {
      "Id": "4a8c41a8-9cd9-5d21-03a1-3d6885830ec9",
      "Name": "TestVariable",
      "Value": "Test2",
      "Description": null,
      "Scope": {
        "Environment": [
          "Environments-21"
        ]
      },

I look forward to hearing from you.

Regards,
Paul

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