Hi guys, I have a deployment that consists from one small script, that fetches some IIS properties of the site associated with my tenant.
And I want to return fetched info from this deployment to my C# client, which I use to start the deployment.
So I have C# client and there I prepare a deployment, get its task and wait for it to finish
var deploymentCreated = _repository.Deployments.Create(deployment);
var task = _repository.Tasks.Get(deploymentCreated.TaskId);
var result = _repository.Tasks.GetDetails(task);
I created a variable called “result” in project, but I can’t see it’s value anywhere in my result object or task object.
My best guess was
var resultVariable = _repository.VariableSets.Get(deploymentCreated.ManifestVariableSetId).Variables.FirstOrDefault(v => v.Name == "result");
but it’s Value is null.
And here is how I am setting the variable value in the Octopus powershell script:
Set-OctopusVariable -name "result" -value "testresult"
Please help me, I’m in despair
Thanks for reaching out! I have a couple of points to mention that might help you get to the bottom of this:
Variables created via
Set-OctopusVariable are called Output Variables. These variables are only available in steps that come AFTER the step where they were created on. So if you are creating them in step
1, they’ll be available from step
To fetch a variable value from a C# script you need to use the syntax shown in this example: https://octopus.com/docs/deployment-examples/custom-scripts/output-variables#using-the-variable-in-another-step ( make sure to click on the
If you want to know if your variable is available in a specific step during your deployment, you can follow this other doc. This way you’ll print all the variables and their values at each point of the deployment.
If after those steps you still find yourself in a struggle, please send me the log file from step (3) so I can take a look at it. If it contains sensitive info feel free to email it to
Hi @Dalmiro, thanks for your reply.
You misunderstood what I need.
I do not use C# script in deployment step, I use C# client library. This one: https://github.com/OctopusDeploy/OctopusClients
And I need to fetch this variable using this client AFTER deploy is completed. Do you know any ways to do this?
I figures it out myself, so here is my precious piece of code for anyone who will ever google such question:
var pages = _repository.VariableSets.Get(deploymentCreated.ManifestVariableSetId).Variables.FirstOrDefault(v => v.Name.Contains("Output.result"));
Sorry I misundestood your initial reply! I’m glad to hear you figured it out yourself. Thanks for taking the time to come back here and posting your solution to the community!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.