Hey Guys,
If anyone would like to Post an Announcement to Yammer during or at the end of a Release the following sample Step Template may be helpful.
It would be nice if the guys at Octopus could add this to the default offering.
Step Template
{
"Id": "ActionTemplates-29",
"Name": "e5 - Post Annnouncement to Yammer",
"Description": null,
"ActionType": "Octopus.Script",
"Version": 69,
"CommunityActionTemplateId": null,
"Properties": {
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.RunOnServer": "false",
"Octopus.Action.Script.ScriptBody": "$uri = \"https://www.yammer.com/api/v1/messages.json\"\r\n$YammerToken = $OctopusParameters['Yammer.Token']\r\n$YammerBody = $OctopusParameters['Yammer.Body']\r\n$YammerGroupId = $OctopusParameters['Yammer.GroupId']\r\n$YammerTitle = $OctopusParameters['Yammer.Title']\r\n\r\n$Payloadjson = '{\"body\":' + '\"' + $YammerBody + '\"' + ', \"group_id\": ' + $YammerGroupId + ', \"is_rich_text\":\"true\", \"message_type\":\"announcement\", \"title\":' + '\"' + $YammerTitle + '\"' + '}'\r\n\r\n$headers = New-Object \"System.Collections.Generic.Dictionary[[String],[String]]\"\r\n$headers.Add(\"Accept\", '*/*')\r\n$headers.Add(\"Authorization\", 'Bearer ' + $YammerToken)\r\n$headers.Add(\"accept-encoding\", 'gzip') \r\n$headers.Add(\"content-type\", 'application/json') \r\n \r\nInvoke-RestMethod -Method Post -Uri $uri -Header $Headers -Body $Payloadjson",
"Octopus.Action.Script.ScriptFileName": null,
"Octopus.Action.Package.FeedId": null,
"Octopus.Action.Package.PackageId": null
},
"Parameters": [
{
"Id": "8db527a8-0130-47fb-9494-fbcb1ba3afde",
"Name": "Yammer.Body",
"Label": "Yammer.Body",
"HelpText": "Yammer Message Body",
"DefaultValue": "<bold>Hello from Octopus Deploy</bold>",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "15c6a914-ad15-41c6-b155-61b730c99194",
"Name": "Yammer.Token",
"Label": "Yammer.Token",
"HelpText": "Yammer Token",
"DefaultValue": "692512-RlA6XBgsFBVFlsl5GSmA",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "54a5f987-3d06-436e-9744-6aa682dcc6b3",
"Name": "Yammer.GroupId",
"Label": "Yammer.GroupId",
"HelpText": "Yammer Message GroupId",
"DefaultValue": "13075741",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "62d033e3-aea2-4344-88ce-5f97ea1d519f",
"Name": "Yammer.Title",
"Label": "Yammer.Title",
"HelpText": "Yammer Title",
"DefaultValue": "Post from Octopus Deploy",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
}
],
"$Meta": {
"ExportedAt": "2017-10-25T02:36:31.998Z",
"OctopusVersion": "3.17.6",
"Type": "ActionTemplate"
}
}
I have use this step to post a Release Announcement to a particular Yammer group
Sample values for Variables
Yammer.Title Variable
#{Octopus.Project.Name} #{Octopus.Release.Number} deployed to #{Octopus.Deployment.Tenant.Name}.#{Octopus.Environment.Name}.#{Octopus.Machine.Name} - #{if Octopus.Deployment.Error}
Failed
#{/if} #{unless Octopus.Deployment.Error}
Succeeded
#{/unless}
Yammer.Body Variable
<h2>Deployment of #{Octopus.Project.Name} #{Octopus.Release.Number} to #{Octopus.Deployment.Tenant.Name}.#{Octopus.Environment.Name}.#{Octopus.Machine.Name}</h2>
<p>
<em>Initiated by
#{unless Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.Username}#{/unless}
#{if Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.DisplayName}#{/if}
#{if Octopus.Deployment.CreatedBy.EmailAddress} (<a href='mailto: #{Octopus.Deployment.CreatedBy.EmailAddress}'>#{Octopus.Deployment.CreatedBy.EmailAddress}</a>)#{/if}
at #{Octopus.Deployment.Created}</em>
</p>
#{if Octopus.Deployment.Error}
<p>
<h3>Error Details</h3>
#{Octopus.Deployment.Error}
<br>
<p>#{Octopus.Deployment.ErrorDetail}</p>
</p>
#{/if}
#{if Octopus.Machine.Hostname}
<br>
<p>Goto <a href='#{e5.Anywhere.IIS.Protocol}://#{e5.Anywhere.IIS.HostNameAndPort}/swagger/index.html'>e5Anywhere Swagger index</a>
</p>
#{/if}
#{unless Octopus.Machine.Hostname}
<br>
<p>Download e5Anywhere from file://///prdbuild/c$/Octopus/Offline Package Drop/#{Octopus.Deployment.Tenant.Name}/#{Octopus.Environment.Name}/#{Octopus.Project.Name}/#{Octopus.Release.Number}</p>
#{/unless}
<p>View the <a href='https://#{Octopus.Deployment.Tenant.Name}.statuspage.io/'>release status</a>
</p>
<p>View the <a href='#{Octopus.Server.Host}#{Octopus.Web.DeploymentLink}'>detailed deployment log</a></p>