Can you help me to pass values for prompt variables for a Deployment using Octopus.Client.dll.
Below is the code I am using to deploy, but I am not able to pass the variables.
I want to pass values for 2 variables
• Octopus.Machine.Names
• Octopus.Machine.Status
So passing the FormValues works for Prompt Variables which are not marked Required.
But next issue wherer I am stuck at is the values passed via FormValues are not used at all.
The Deployment is using the default values set for the Prompt Variables.
So passing the FormValues works for Prompt Variables which are not marked Required .
Here you say they are working for Required variables
But next issue wherer I am stuck at is the values passed via FormValues are not used at all.
The Deployment is using the default values set for the Prompt Variables.
But here you say the values are not being used (and the default ones are prevailing), which makes me think this is not really working?
Is there any chance you can send me:
The full C# script you are using to create the release
var server = “https://myoctopus”;
var apiKey = “API-SOMEAPIKEY”; // Get this from your ‘profile’ page in the Octopus web portal
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var environment = repository.Environments.FindByName("MyEnv");
var release = repository.Releases.FindOne(x => x.ProjectId == "MyProject" && x.Version == "0.0.1");
//creating the deployment object
var deployment = new DeploymentResource
{
ReleaseId = release.Id,
ProjectId = "MyProject",
EnvironmentId = environment.Id,
FormValues = new Dictionary<string, string>
{
{ "Var1", "102" },
{ "Var2", "200" }
}
};
//Deploying the release in Octopus
var result = repository.Deployments.Create(deployment);
Var1 is setup as a prompt variable with Required checkbox unchecked.
default value for Var1 is set to “101”
If I pass value “102” as above, the default value still prevails.
I dug into this a bit more, and it seems that passing prompted variables using the Octopus.Client required you to jump through a bit more hoops than I remembered.