【问题标题】:Powershell Variable Substitution in Octopus DeployOctopus Deploy 中的 Powershell 变量替换
【发布时间】:2014-05-14 08:11:45
【问题描述】:

我有一个非常简单的 powershell 脚本,用于在特定组件上完成部署时通知 newrelic。我遇到的问题是我无法正确发送版本号。

我使用的脚本是:

$NewRelicUri = "https://api.newrelic.com/deployments.xml"
$body = @{ 
    "deployment[app_name]" = "PB.Website"; 
    "deployment[revision]"= "#{Octopus.Release.Number}"; 
} 

Write-Host "Sending notification to $NewRelicUri..."
Invoke-WebRequest -Uri $NewRelicUri -Headers @{ "x-api-key"="XXX" } -Method Post -Body $body -UseBasicParsing

这会生成一个带有修订版#{Octopus.Release.Number} 的newrelic 部署。我也尝试过使用$OctopusParameters['Octopus.Release.Number'] 的长手版本,但这会产生一个修订版为System.Collections.Generic.Dictionary``2[System.String,System.String]['Octopus.Release.Number'] 的部署

我怎样才能让章鱼把实际的发行号发送到newrelic?

【问题讨论】:

  • 不要使用newrelic,所以我不能真正测试,但我会试试这个:"deployment[revision]"= "$($OctopusParameters['Octopus.Release.Number']) "
  • 完成了这项工作。想将您的评论移至答案以便我接受吗?
  • 完成。很高兴解决了它!

标签: powershell octopus-deploy


【解决方案1】:

我不使用 NewRelic,所以我无法对其进行真正的测试,但是您在长期版本中遇到的错误表明您需要为该值使用子表达式:

 "deployment[revision]"= "$($OctopusParameters['Octopus.Release.Number'])" 

如果版本号已经是字符串,您可能只需:

"deployment[revision]" = $OctopusParameters['Octopus.Release.Number']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多