Octopus.Script exported 2014-06-11 by bobjwalker belongs to ‘HipChat’ category.
Send a success notification when this step is executed.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Room Id
HipChatRoomId
null
Auth token
HipChatAuthToken
For API version 1.
From name
HipChatFrom = Octopus Deploy
null
Color
HipChatColor = green
HipChat message color
Message
HipChatMessage
You can use variables here. Leave blank for the default build notification format.
Script body
Steps based on this template will execute the following PowerShell script.
$message = if ($OctopusParameters['HipChatMessage']) { $OctopusParameters['HipChatMessage'] } else { "(successful) " + $OctopusParameters['Octopus.Project.Name'] + " [v$($OctopusParameters['Octopus.Release.Number'])] deployed to $($OctopusParameters['Octopus.Environment.Name']) on $($OctopusParameters['Octopus.Machine.Name'])" }
#---------
$apitoken = $OctopusParameters['HipChatAuthToken']
$roomid = $OctopusParameters['HipChatRoomId']
$from = $OctopusParameters['HipChatFrom']
$colour = $OctopusParameters['HipChatColor']
Try
{
#Do the HTTP POST to HipChat
$post = "auth_token=$apitoken&room_id=$roomid&from=$from&color=$colour&message=$message¬ify=1&message_format=text"
$webRequest = [System.Net.WebRequest]::Create("https://api.hipchat.com/v1/rooms/message")
$webRequest.ContentType = "application/x-www-form-urlencoded"
$postStr = [System.Text.Encoding]::UTF8.GetBytes($post)
$webrequest.ContentLength = $postStr.Length
$webRequest.Method = "POST"
$requestStream = $webRequest.GetRequestStream()
$requestStream.Write($postStr, 0,$postStr.length)
$requestStream.Close()
[System.Net.WebResponse] $resp = $webRequest.GetResponse();
$rs = $resp.GetResponseStream();
[System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;
$sr.ReadToEnd();
}
catch [Exception] {
"Woah!, wasn't expecting to get this exception. `r`n $_.Exception.ToString()"
}
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "c37ccd22-2b31-4263-8389-9e63868519b4",
"Name": "HipChat - Notify (API v1)",
"Description": "Send a success notification when this step is executed.",
"Version": 5,
"ExportedAt": "2014-06-11T02:21:16.787+00:00",
"ActionType": "Octopus.Script",
"Author": "bobjwalker",
"Parameters": [
{
"Name": "HipChatRoomId",
"Label": "Room Id",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "HipChatAuthToken",
"Label": "Auth token",
"HelpText": "For API version 1.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "HipChatFrom",
"Label": "From name",
"HelpText": null,
"DefaultValue": "Octopus Deploy",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "HipChatColor",
"Label": "Color",
"HelpText": "HipChat message color",
"DefaultValue": "green",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "HipChatMessage",
"Label": "Message",
"HelpText": "You can use variables here. Leave blank for the default build notification format.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptBody": "$message = if ($OctopusParameters['HipChatMessage']) { $OctopusParameters['HipChatMessage'] } else { \"(successful) \" + $OctopusParameters['Octopus.Project.Name'] + \" [v$($OctopusParameters['Octopus.Release.Number'])] deployed to $($OctopusParameters['Octopus.Environment.Name']) on $($OctopusParameters['Octopus.Machine.Name'])\" } \n#---------\n$apitoken = $OctopusParameters['HipChatAuthToken']\n$roomid = $OctopusParameters['HipChatRoomId']\n$from = $OctopusParameters['HipChatFrom']\n$colour = $OctopusParameters['HipChatColor']\n\nTry \n{\n\t#Do the HTTP POST to HipChat\n\t$post = \"auth_token=$apitoken&room_id=$roomid&from=$from&color=$colour&message=$message¬ify=1&message_format=text\"\n\t$webRequest = [System.Net.WebRequest]::Create(\"https://api.hipchat.com/v1/rooms/message\")\n\t$webRequest.ContentType = \"application/x-www-form-urlencoded\"\n\t$postStr = [System.Text.Encoding]::UTF8.GetBytes($post)\n\t$webrequest.ContentLength = $postStr.Length\n\t$webRequest.Method = \"POST\"\n\t$requestStream = $webRequest.GetRequestStream()\n\t$requestStream.Write($postStr, 0,$postStr.length)\n\t$requestStream.Close()\n\t\n\t[System.Net.WebResponse] $resp = $webRequest.GetResponse();\n\t$rs = $resp.GetResponseStream();\n\t[System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs;\n\t$sr.ReadToEnd();\t\t\t\t\t\n}\ncatch [Exception] {\n\t\"Woah!, wasn't expecting to get this exception. `r`n $_.Exception.ToString()\"\n}",
"Octopus.Action.Script.Syntax": "PowerShell"
},
"Category": "HipChat",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/hipchat-notify-api-v1.json",
"Website": "/step-templates/c37ccd22-2b31-4263-8389-9e63868519b4",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////HVCAvMvZaourDJE3ngAABCpJREFUeNrsXe12KyEI3DDv/85N2rT52igrg2DK3D/tPafqCCIqsNtWKBQKhUKhUCgUCoVCoVAoFAoFZ4gILjj94fvX838vxOF++Hs488kvhw6HOzZ5ZaMncSPzCSwychllkYyLicWVy+rCSCMWFo1gKkwagVTYNKKoONCIWPZycsNUoZw8MU+/dFr14+v+elTfPwJIpF/9RY6mQyiioBO/OpQuepeMhKrVIde84/IjbJWPrNEWF8Qsj2FTgwD1Ep8uZfaSFze7/1bSMpOHpG9c1ZWs0n67H6plwQwmMsMp2l8q4s9j0nbLZBJrUVx5uO27cFRhTPUf/HqTyb6pzNurnH1spx4jTj0efSLidkD4y0QiTqF7MpFsDQZNIMJunYTbc+DtmTBFgsgLTWLnEnsxC5o6IE6xqPMosTx4A0D4Qx9pBNECeRXJqgIhjSHENXEYhKR4CoddvZFBIM8igbmFsEdw83xKDoHYJxRZgkWsA0miWWbVSKNZ1ilFFoE8zyn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