Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,849
Community Members
 
Community Events
168
Community Groups

OEC (Windows Service) action with PowerShell - how do I see (grab) the alert parameters or payload?

Can someone provide an example of the OEC json configuration and the powershell method to capture the globalargs passed?

1 answer

0 votes
Connor Eyles Atlassian Team May 26, 2021

Hi @tolkien_leung 

Here are some instructions on how to handle OEC payload in Powershell:

The environment this was tested in is Windows 2012 and above… Powershell 3 and above.

Starting at linerps 1 of your PowerShell script you should define the parameters that PowerShell is expected to receive from OEC, these are payload, apiKey, opsgenieUrl, and logLevel.

param([string]$payload,
[string]$apiKey,
[string]$opsgenieUrl,
[string]$logLevel)

Once the parameters have been defined you need to convert the payload from JSON to a Powershell object.

$payloadPsObj = $payload | ConvertFrom-Json

Now you can call your data like this, to get the payload data you can use $payloadPsObj.<Namespace or array index>, for example, the below will get you the alertId from the payload:

$alertDetails = $payloadPsObj.alert
$alertId = $alertDetails.alertId

echo $alertId

The full final script should look like this:

param([string]$payload,
[string]$apiKey,
[string]$opsgenieUrl,
[string]$logLevel)

$payloadPsObj = $payload | ConvertFrom-Json

$alertDetails = $payloadPsObj.alert
$alertId = $alertDetails.alertId

echo $alertId

Thanks,

Connor

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

172 views 1 6
Read article

Atlassian Community Events