I am trying to update a newly created release’s variable set using the Octopus.Client .net client.
The error returned is as follows:
There was a problem with your request.
- You cannot modify this variable set because the set is frozen. You’ll need to create a new variable set instead.
Any assistance would be appreciated.
Thanks you for getting in touch. It looks like you are trying to modify a snapshot of a variable set ('IsFrozen: true
), which is not allowed. These also have an id with-s-` after the projectId.
To modify the current variables for a project, you need to fetch the current variable set for the project. The easiest way to do that is to use the
VariableSetId on the project, eg:
var project = repository.Projects.FindByName("MyProject");
var variables = repository.VariableSets.Get(project.VariableSetId);
Thanks for your response. I am not trying to modify the variable set of a project. I am trying to update the variable snapshot of a created release. Below is a snippet of my code.
var octopusProject = await this.FindProject(projectName); // External method
var octopusRelease = await this.FindProjectRelease(octopusProject.Id, projectRelease); // Extermal method
var variableSet = await this.octopusAsyncRepository.VariableSets.Get(octopusRelease.ProjectVariableSetSnapshotId);
var variableResource = variableSet.Variables.FirstOrDefault((variable) => variable.Name == “testVariable”);
variableResource.Value = “testValue”;
var updatedVariableSet = await this.octopusAsyncRepository.VariableSets.Modify(variableSet);
The last call comes back with the error specified above.
The only way to update the variables on an existing release is to re-snapshot the current variable set. You can do this via the
How do you update the variable set with this method though? As far as I can see you can only pass in a ReleaseResource object. There is no way to specify or update any of the variables in the VariableSet associated with the release.
I would appreciate it if you could point me to a more detailed documentation or example of how I would achieve this.
That will update the variable set with whatever the current variables are on the project. It is the function used by the “Update Variables” button in the Web UI. We do not allow the release variables to be set to an arbitrary set.
You can find further documentation here: https://github.com/OctopusDeploy/OctopusDeploy-Api/wiki/Releases
Also it is often useful to check how the Web UI does things (by checking the calls in developer tools), or how the commands operate in the
octo.exe tool (https://github.com/OctopusDeploy/OctopusClients/tree/master/source/Octo/Commands)