Showing posts with label tenant variables. Show all posts
Showing posts with label tenant variables. Show all posts

Thursday, September 7, 2023

Step-by-Step Guide to Updating Env Config Variables in Octopus Project

Step-by-Step Guide to Updating Env Config Variables in Octopus Project -

  1. Open the Octopus project for which you want to update the Env Config variables.

  2. In the left-hand navigation pane, click Variables > Project Templates.

  3. Add the required project templates along with their values.

  4. Click Save.

  5. Click Tenants from the menu.

  6. Select the required tenant.

  7. Click Variables.

  8. Expand the required project to update the variable names.

  9. Update the variables and click Save.

  10. Return to the Octopus project.

  11. Click Process.

  12. Add the Octopus Admin and Service Fabric modules from the Script Modules section.

  13. Click the Add step (Run a script).

Test Env Config file:

hostname = hostname_value

Use the following PowerShell script to update the Env Config variables:

#Test [String]$hostname = "" Write-Message -Message ("Validating Test Variables ....") ##Validate Test Variables For Successful Deployment

$hostname = Validate-SFParameters -Value $OctopusParameters['hostname'] -ParameterName "hostname" -ReturnValue Write-Header -Header "END VALIDATING VARIABLES"; ## -------------------------------------------------------------------------------------- ## Update the variables in the Config file ## -------------------------------------------------------------------------------------- $config_file_path = "C:\config\default.config" # Open the config file $config_file = Get-Content -Path $config_file_path $config_file = $config_file -replace "(?<=^|\W)hostname_value(?=\W|$)", $hostname # Write the config file Set-Content $config_file_path $config_file

14. Create the release

15. Open the test environment configuration file in the project directory and verify that the configurations have been updated.