Skip to content

Commit

Permalink
Update to match contributing guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson committed May 22, 2018
1 parent 49d4688 commit 272228f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions step-templates/victorops-create-alert.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"Id": "2ecb9ec9-2c81-4e75-8093-175d2557ca54",
"Name": "Create VictorOps Alert",
"Name": "VictorOps - Create Alert",
"Description": "Create an alert in VictorOps via the REST integration. See [VictorOps docs](https://help.victorops.com/knowledge-base/victorops-restendpoint-integration/) for details.",
"ActionType": "Octopus.Script",
"Version": 20,
"Version": 24,
"CommunityActionTemplateId": null,
"Properties": {
"Octopus.Action.Script.ScriptBody": "Set-StrictMode -Version Latest\r\n\r\nfunction Send-VictorOpsAlert($url, $messageType, $entityDisplayName, $stateMessage, $customFields)\r\n{\r\n $payload = @{\r\n \"message_type\" = $messageType\r\n \"entity_display_name\" = $entityDisplayName\r\n \"state_message\" = $stateMessage\r\n }\r\n\r\n write-verbose \"Splitting custom fields\"\r\n foreach($line in $customFields -split \"`n\") {\r\n write-verbose \" - line is '$line'\"\r\n $kv = $line.Split('|')\r\n write-verbose \" - kv is '$kv'\"\r\n $payload.Add($kv[0], $kv[1])\r\n }\r\n\r\n write-verbose \"Submitting payload`n$payload`n to $url\"\r\n\r\n try {\r\n $response = Invoke-Restmethod -Method POST -Uri $url -Body ($payload | ConvertTo-Json) -ContentType \"application/json\"\r\n write-host \"Successfully submitted\"\r\n } catch {\r\n Fail-Step \"Failed to submit VictorOps alert - $($_)\"\r\n }\r\n\r\n}\r\n\r\nif (Test-Path variable:OctopusParameters) {\r\n Send-VictorOpsAlert -url $OctopusParameters['VictorOpsAlertUrl'] `\r\n -messageType $OctopusParameters['VictorOpsMessageType'] `\r\n -entityDisplayName $OctopusParameters['VictorOpsEntityDisplayName'] `\r\n -stateMessage $OctopusParameters['VictorOpsMessage'] `\r\n -customFields $OctopusParameters['VictorOpsCustomFields']\r\n}",
"Octopus.Action.Script.ScriptBody": "Set-StrictMode -Version Latest\n\nfunction Send-VictorOpsAlert($url, $messageType, $entityDisplayName, $stateMessage, $customFields)\n{\n $payload = @{\n \"message_type\" = $messageType\n \"entity_display_name\" = $entityDisplayName\n \"state_message\" = $stateMessage\n }\n\n if (-not ([string]::IsNullOrEmpty($customFields))) { \n foreach($line in $customFields -split \"`n\") {\n if (-not ([string]::IsNullOrEmpty($line))) { \n if ($line -like '*|*') {\n $kv = $line.Split('|')\n $payload.Add($kv[0], $kv[1])\n } else {\n write-verbose \"The line '$line' in 'Custom fields' contained invalid data. Please ensure its a list of key value pairs, separated by '|'.\"\n }\n }\n }\n }\n\n write-verbose \"Submitting payload`n$($payload | ConvertTo-Json)`n to $url\"\n\n try {\n $response = Invoke-Restmethod -Method POST -Uri $url -Body ($payload | ConvertTo-Json) -ContentType \"application/json\"\n write-host \"Successfully submitted\"\n write-verbose \"Response was `n$($response | ConvertTo-Json)\"\n } catch {\n Fail-Step \"Failed to submit VictorOps alert - $($_)\"\n }\n\n}\n\nif (Test-Path variable:OctopusParameters) {\n if ([string]::IsNullOrEmpty($OctopusParameters['VictorOpsAlertUrl'])) {\n \tWrite-Host \"Please provide the VictorOps Url\"\n exit 1\n }\n if ([string]::IsNullOrEmpty($OctopusParameters['VictorOpsMessageType'])) {\n \tWrite-Host \"Please provide a valid Message Type\"\n exit 1\n }\n if ([string]::IsNullOrEmpty($OctopusParameters['VictorOpsEntityDisplayName'])) {\n \tWrite-Host \"Please provide a valid Title\"\n exit 1\n }\n if ([string]::IsNullOrEmpty($OctopusParameters['VictorOpsMessage'])) {\n \tWrite-Host \"Please provide a valid Message\"\n exit 1\n }\n Send-VictorOpsAlert -url $OctopusParameters['VictorOpsAlertUrl'] `\n -messageType $OctopusParameters['VictorOpsMessageType'] `\n -entityDisplayName $OctopusParameters['VictorOpsEntityDisplayName'] `\n -stateMessage $OctopusParameters['VictorOpsMessage'] `\n -customFields $OctopusParameters['VictorOpsCustomFields']\n}",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.ScriptFileName": null,
"Octopus.Action.Package.FeedId": null,
"Octopus.Action.Package.PackageId": null
"Octopus.Action.Script.ScriptSource": "Inline"
},
"Parameters": [
{
Expand Down Expand Up @@ -63,7 +60,7 @@
"Id": "525a75a3-db7d-45dd-99c1-d9821d527cbe",
"Name": "VictorOpsCustomFields",
"Label": "Custom fields",
"HelpText": "A list of keyvalue pairs (separated by `|`), one per line. eg: \nEnvironment|Production\nRegion|us-west-1",
"HelpText": "A list of keyvalue pairs (separated by `|`), one per line. eg: \n```\nEnvironment|Production\nRegion|us-west-1\n```",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "MultiLineText"
Expand Down

0 comments on commit 272228f

Please sign in to comment.