gpt4 book ai didi

octopus-deploy - 从八达通获取用户变量列表

转载 作者:行者123 更新时间:2023-12-03 20:18:58 28 4
gpt4 key购买 nike

我们有 Octopus-2.0。
我们将服务凭证(它们是每台机器的)存储在 octopus 用户变量中。
我还需要在 SQL 服务器中创建这些登录名。

例如服务登录名“machine1_service1”存储为变量名。该登录名的密码存储在八达通的变量值列下。

到目前为止,我知道对于来自 Octopus 的任何变量值,我们都需要提供准确的变量名。但在这种情况下,我实际上需要获取所有这些变量的列表。

有没有办法做到这一点?

最佳答案

是的。

Octopus 变量可从可枚举的字典对象访问。如果您遵循命名约定,您可以使用 powershell 查询字典,如下所示。这将在自定义步骤中或您可以编写自己的 powershell 的某个地方调用,例如.nu​​get 文件中的 PostDeploy.ps1 脚本

假设变量是这样定义的

enter image description here

您可以使用此 powershell 访问它们并枚举它们

# Get service accounts
$serviceAccounts = $OctopusParameters.keys | ? {$_ -like "service-*"}
write-host "Accounts found:" $serviceAccounts.count

foreach($account in $serviceAccounts)
{
write-host "Account: $account"

$password = $OctopusParameters[$account]
write-host "Password: $password"
}

希望这可以帮助。

关于octopus-deploy - 从八达通获取用户变量列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31924055/

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