Hi,
I’m trying to add a variable to my project using the Octopus Client (ver 3.3.17 & 3.3.20) on Octopus (ver 3.3.17). I can see the variable being added, but can’t see the scope. The code is as follows:
class X
{
private const string VARIABLE_API_KEY = “API-XXXXXXXXXXXXXXXXXXXXXXXX”;
private const string SERVER = “http://octopus.mycompany.com”;
public void AddVar()
{
var repository = new OctopusRepository(
new OctopusServerEndpoint(SERVER, VARIABLE_API_KEY));
// find the project
var project = repository.Projects.FindByName("MyProject");
// get deployment process and steps
var id = project.DeploymentProcessId;
var deploymentProcess = repository.DeploymentProcesses.Get(id);
var steps = deploymentProcess.Steps;
//get get project level variable set
var defaultVariableSet = repository.VariableSets.Get(project.Link("Variables"));
var res = new VariableResource();
res.Name = "TEST123";
res.Value = "vale";
// add the scoped variable and save
res.Scope.Add(ScopeField.Action, new ScopeValue(steps[3].Name));
defaultVariableSet.Variables.Add(res);
repository.VariableSets.Modify(defaultVariableSet);
}
}
please HELP. Urgent