Add or Update values in OctopusParameters

Is there a way to add or update variables in the OctopusParameters array?

The syntax for referencing output variables is too cumbersome for us at this point. We have several steps down stream that have references like this #{myVar}.

We have modified our deployment process to include a new step that generates output vars. Now we have to go back through all of the subsequent steps and update many references to #{Octopus.Action[StepB].Output.myVar}.

It would be much easier to update the value myVar somehow via that step or in some cases add a new var to OctopusParameters.

Hi Colin,

Thanks for getting in touch! Currently there is no method in Octopus for making bulk changes like this inside your steps. However, I believe there are some possible options available here depending on what would work for you.

First thing I will note is that this would technically be possible by writing a script to interact with the Octopus API. You can retrieve the deployment process for your project(s) and have your script replace the instances of #{myVar} with your desired value.

If you decide to do this via the API I can provide you with a link to our internal collection of PowerShell API scripts.

We have another possible simplified solution which may help here is the Binding Syntax. You can keep the #{myVar} variable throughout the deployment and create a project variable with the name myVar and specify a value of #{Octopus.Action[StepB].Output.myVar}. This will evaluate any instance of #{myVar} to the value the outputut variable evaluates to.

In my deploy-nuget step I have: Set-OctopusVariable -name "myVar" -value "xyzxyz"
In a subsequent script step I have Write-Host #{myVar} which successfully evaluates to xyzxyz during deployment.

This solution is more of a workaround than anything any may not be appropriate for your situation.

If you have any further thoughts or questions here, or if I have misinterpreted your question, please let me know. :slight_smile:

Best regards,

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.