Heya,
So Im having an issue getting Octopus to substitute values in a web.config file with output variables from another step.
I have a step called “GetTransformVariables.” In this step i have a power shell script that is only good for getting dynamic data that I cannot store in a variable set (password from azure, etc)
heres a sample of the script
### TRANSFORM STUFF!!!
###### Doc DB Stuff
Write-Host ""
Write-Host "-------------------------------"
Write-Host "Getting DocDb Stuff"
Write-Host ""
$keys = Invoke-AzureRmResourceAction -Action listKeys -ResourceType "Microsoft.DocumentDb/databaseAccounts" -ApiVersion "2016-03-31" -ResourceGroupName $GroupName -Name $DbName -Force
$keys | Out-String | Write-Host
$primaryKey = $keys.primaryMasterKey
Set-OctopusVariable -name "DocDbAuthKey" -value "$primaryKey"
Set-OctopusVariable -name "DocDbName" -value "$DbName"
So now… in a later step… I want to take the DocDbAuthKey and put it in a config file.
I added this to the web.release.config file for transformation
<add key="DocDbAuthKey"
value="#{Octopus.Action[GetTransformVariables].Output.DocDbAuthKey}"
xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
Note: The transform appears to work as expected.
So i run the deployment with both steps and the transform appears to work but the variable replacement does not work
<add key="DocDbAuthKey" value="#{Octopus.Action[GetTransformVariables].Output.DocDbAuthKey}" />
Well… that’s odd… so I checked to see if the variable was available in the step.
I added this to the pre-deployment script for the second step
$primaryKey = $OctopusParameters["Octopus.Action[GetTransformVariables].Output.DocDbAuthKey"]
$DocDbName = $OctopusParameters["Octopus.Action[GetTransformVariables].Output.DocDbName"]
Write-Host "$primaryKey ||| $DocDbName"
And sure enough… theres the output in the log (not going to show it, it contains sensitive info… trust me on this… it was there).
Here’s the funny part!
The variable substitution appears to work if I set the variable on the same step as the transform happens.
I added this to the Second Step
Set-OctopusVariable -name "DocDbAuthKey" -value "$primaryKey"
And reran the deployment… and it worked!!! welp… that’s good except it doesnt solve my issue. I would like to have one step that will gather all the dynamic variables for all the following steps. If I have to put this in every step (currently have about 20 steps in this deployment) then maintaining it will get really messy… really quickly.
Some Environment Details
- Octopus Version 3.16.5