Pergunta

I have a very simple powershell script to notify newrelic when a deployment completes on a particular component. The problem I have is that I can't get the release number to be sent correctly.

The script I am using is:

$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

This produces a deployment in newrelic with the revision #{Octopus.Release.Number}. I have also tried using the long hand version of $OctopusParameters['Octopus.Release.Number'], but this produces a deployment with a revision of System.Collections.Generic.Dictionary``2[System.String,System.String]['Octopus.Release.Number']

How can I get octopus to put send the actual release number to newrelic?

Foi útil?

Solução

I don't use NewRelic, so I can't really test it, but that error your getting in your long hand version indicates you need to use a subexpression for that value:

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

If the release number is already as string, you might get by with just:

"deployment[revision]" = $OctopusParameters['Octopus.Release.Number']
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top