
I'd like to specify an environment variable, so I could verify whether it's a stage/production/development environment (either ASPNETCORE_Environment or a custom one). Does Octopus do it by default or do I have to set it up manually?
2 Answers
During the deployment the variable #{Octopus.Environment.Name}
will resolve to the name of the Octopus Environment you are deploying to. Following the image below:
- If you deploy to environment (1),
#{Octopus.Environment.Name}
will resolve toDevelopment
. - (2) ->
Staging
- (3) ->
Test
But this variable will only be available within the context of the Octopus deployment. If you are looking to set something more persistent you're gonna have to Powershell your way through it using a script step in your deployment process with the below:
[System.Environment]::SetEnvironmentVariable("MyPassword","P4$$w0rd123", [System.EnvironmentVariableTarget]::Machine)
More info about the above command in this blog post
3Octopus has a set of system variables. The one you asking about is:
#{Octopus.Environment.Name}
ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobGlsY2eGd4KOrJytrJmjtG6xza%2Bgq6eeorKvwIyvmKuhkZe5pr%2BMoqVmp5OpvLHB0g%3D%3D