Octopus Deploy - 部署目标机器名称的变量替换
Octopus Deploy - variable replacement for deployment target machine name
问题:
我有一个手动干预步骤,其中包含执行部署的人员要遵循的文本步骤。
我想传递目标服务器的名称,这样此人就不需要查找目标服务器名称。
例如,如下所示,我需要将它们解压缩到目标服务器上的某个位置。
**SECTION 1: (Main installation)**
1. Navigate to: #{InstallationZipLocation}.
2. Download zip file named: #{ZipFileName}
3. Unzip to the desktop on: #{DeploymentTargetMachineName} --need help here
4. Run executable named: #{ExecutableName}
5. Accept default settings
我试过的:
Octopus Deploy - System Variables Documentation 优惠:
#{Octopus.Deployment.Machines}
结果:Machines-6
#{Octopus.Deployment.SpecificMachines}
结果:</code>(空字符串)</p>
<hr>
<p><strong>我希望看到的:</strong></p>
<pre><code>3. Unzip to the desktop on: FTPServer05
附加评论:
我意识到我可以在我的变量列表中为每个目标 environment/scope 设置目标服务器的名称,结果只有 4 个变量(没什么大不了的,而且易于维护),但我很好奇是否有办法来简化它。我们是 运行 Octopus Deploy 3.12.9.
所以我一直在寻找一种更简单的方法,但偶然发现了一些我发现相当有趣的东西,所以我继续实施它。
Output variables。 . . "After a step runs, Octopus captures the output variables, and keeps them for use in subsequent steps."
我为解决问题所做的工作:
我设置了一个自定义 step-template,其唯一目的是设置 "output variables" 以在我的后续步骤中使用。您可以将此作为项目的第一步,或者至少在引用您正在设置的变量的步骤之前。
自定义步骤设置:
Powershell:
Write-Host "TargetDeploymentMachineName $TargetDeploymentMachineName"
Set-OctopusVariable -name "TargetDeploymentMachineName" -value $TargetDeploymentMachineName
参数:
然后在我的手动干预步骤中,我使用这样的输出值:
3. Unzip to the desktop on: #{Octopus.Action[MyProject-Set-Output-Variables].Output.TargetDeploymentMachineName}
(其中 [MyProject-Set-Output-Variables]
代表我的部署项目中负责分配输出变量的步骤的名称)
我的问题为何遇到问题的解释:
原来用于我的问题的 variable binding syntax 应该是:
Octopus.Machine.Name
= The name that was used to register the
machine in Octopus. Not the same as Hostname
但是,手动干预步骤具体没有 "Deployment Target":
它只是在 "Octopus Server":
上运行
所以我很确定这就是我没有得到 "target" 值的原因。例如,我简单地测试了另一个使用 "Deployment Targets" 单选按钮的新基本步骤,结果得到了我期望的 FTPServer05
值。
问题:
我有一个手动干预步骤,其中包含执行部署的人员要遵循的文本步骤。
我想传递目标服务器的名称,这样此人就不需要查找目标服务器名称。
例如,如下所示,我需要将它们解压缩到目标服务器上的某个位置。
**SECTION 1: (Main installation)**
1. Navigate to: #{InstallationZipLocation}.
2. Download zip file named: #{ZipFileName}
3. Unzip to the desktop on: #{DeploymentTargetMachineName} --need help here
4. Run executable named: #{ExecutableName}
5. Accept default settings
我试过的:
Octopus Deploy - System Variables Documentation 优惠:
#{Octopus.Deployment.Machines}
结果:Machines-6
#{Octopus.Deployment.SpecificMachines}
结果:</code>(空字符串)</p>
<hr>
<p><strong>我希望看到的:</strong></p>
<pre><code>3. Unzip to the desktop on: FTPServer05
附加评论: 我意识到我可以在我的变量列表中为每个目标 environment/scope 设置目标服务器的名称,结果只有 4 个变量(没什么大不了的,而且易于维护),但我很好奇是否有办法来简化它。我们是 运行 Octopus Deploy 3.12.9.
所以我一直在寻找一种更简单的方法,但偶然发现了一些我发现相当有趣的东西,所以我继续实施它。
Output variables。 . . "After a step runs, Octopus captures the output variables, and keeps them for use in subsequent steps."
我为解决问题所做的工作:
我设置了一个自定义 step-template,其唯一目的是设置 "output variables" 以在我的后续步骤中使用。您可以将此作为项目的第一步,或者至少在引用您正在设置的变量的步骤之前。
自定义步骤设置:
Powershell:
Write-Host "TargetDeploymentMachineName $TargetDeploymentMachineName"
Set-OctopusVariable -name "TargetDeploymentMachineName" -value $TargetDeploymentMachineName
参数:
然后在我的手动干预步骤中,我使用这样的输出值:
3. Unzip to the desktop on: #{Octopus.Action[MyProject-Set-Output-Variables].Output.TargetDeploymentMachineName}
(其中 [MyProject-Set-Output-Variables]
代表我的部署项目中负责分配输出变量的步骤的名称)
我的问题为何遇到问题的解释:
原来用于我的问题的 variable binding syntax 应该是:
Octopus.Machine.Name
= The name that was used to register the machine in Octopus. Not the same as Hostname
但是,手动干预步骤具体没有 "Deployment Target":
它只是在 "Octopus Server":
上运行所以我很确定这就是我没有得到 "target" 值的原因。例如,我简单地测试了另一个使用 "Deployment Targets" 单选按钮的新基本步骤,结果得到了我期望的 FTPServer05
值。