gpt4 book ai didi

octopus-deploy - Octopus Deploy - 部署目标机器名称的变量替换

转载 作者:行者123 更新时间:2023-12-04 04:31:40 26 4
gpt4 key购买 nike

问题:

我有一个手动干预步骤,其中包含执行部署的人员要遵循的文本步骤。

我想传递目标服务器的名称,这样这个人就不需要查找目标服务器名称。

例如,如下所示,我需要将它们解压缩到目标服务器上的某个位置。

**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优惠:

enter image description here

#{Octopus.Deployment.Machines} 结果:Machines-6

#{Octopus.Deployment.SpecificMachines} 结果:(空字符串)


我希望看到的:

3. Unzip to the desktop on: FTPServer05

附加评论:我意识到我可以在我的变量列表中为每个目标环境/范围设置目标服务器的名称,结果只有 4 个变量(没什么大不了的,而且易于维护),但我很好奇是否有一种方法可以简化它。我们正在运行 Octopus Deploy 3.12.9。

最佳答案

所以我一直在寻找一种更简单的方法,但偶然发现了一些我发现相当有趣的东西,所以我继续实现了它。

Output variables . . . “在一个步骤运行后,Octopus 捕获输出变量,并保留它们以供后续步骤使用。”


我为解决问题所做的工作:

我设置了一个自定义步骤模板,其唯一目的是设置“输出变量”以在我的后续步骤中使用。您可以将此作为项目的第一步,或者至少在引用您正在设置的变量的步骤之前。

自定义步骤设置:

电源外壳:

Write-Host "TargetDeploymentMachineName        $TargetDeploymentMachineName"
Set-OctopusVariable -name "TargetDeploymentMachineName" -value $TargetDeploymentMachineName

参数: enter image description here

然后在我的手动干预步骤中,我使用这样的输出值:

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

但是,手动干预步骤特别没有“部署目标”:

enter image description here

它只是在“八达通服务器”上运行:

enter image description here

所以我很确定这就是我没有获得“目标”值的原因。例如,我只是测试了另一个使用“部署目标”单选按钮的新基本步骤,这导致了我期望的 FTPServer05 值。

关于octopus-deploy - Octopus Deploy - 部署目标机器名称的变量替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49500713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com