How to peform Octopus.SetVariable() through api?

I have a process step that runs a powershell script. The powershell script executes a method in a C# dll that I am developing, The C# library generates my release notes and references the Octopus.Client library I got from Nuget.

Now I need to pass back the release notes from my C# library to Octopus, so I can include them in a notification email.

I have tried modifying the variable sets, which fails because I cannot update the running variable set.

Ik know the existence of the Set-OctopusVariable which can be used from powershell, which would help me out. The C# equivalent Octopus.SetVariable() however is not available in Octopus.Client.dll.

So how do I set an output variable from my C# library?

Thanks!

Hi,
If you are running a C# script step, then you can use the standard Octopus helper functions that are injected into the top of your scripts. This is described in our docs here.

Alternatively if the code you are executing is within another process that does not have access to these methods, you can write the service messages directly to the standard output and the Octopus Server will interpret them as output variables accordingly. The helper methods we supply simply generate these service messages themselves and you can check out how this is done in our open source [Calamari repository(https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari/Integration/Scripting/ScriptCS/Bootstrap.csx#L146)]. I have update our docs with information regarding these service messages to assist others who may have this same question.

Let me know if you have any further questions regarding generating these output variables.
Cheers,
Rob