在八达通中设置环境变量

Setting environment variables in Octopus

我想指定一个环境变量,这样我就可以验证它是否是 stage/production/development 环境(ASPNETCORE_Environment 或自定义环境)。 Octopus 是默认设置还是我必须手动设置?

章鱼有一套system variables。你问的是:

#{Octopus.Environment.Name}

在部署期间,变量 #{Octopus.Environment.Name} 将解析为您要部署到的 Octopus 环境 的名称。按照下图:

  • 如果部署到环境 (1),#{Octopus.Environment.Name} 将解析为 Development
  • (2) -> Staging
  • (3) -> Test

OctopusEnvironments

但此变量仅在 Octopus 部署的上下文中可用。如果你想设置更持久的东西,你将不得不在你的部署过程中使用以下脚本步骤来通过它进行 Powershell:

[System.Environment]::SetEnvironmentVariable("MyPassword","P4$$w0rd123", [System.EnvironmentVariableTarget]::Machine)

有关上述命令的更多信息,请参见 this blog post