Octopus.Script exported 2016-05-11 by bobjwalker belongs to ‘Splunk’ category.
A step template that logs a given message to the Splunk Event Collector along with related Octopus Deploy variables.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
The host endpoint of the Splunk Event Collector
SplunkHost
null
The port of the Event Collector
SplunkEventCollectorPort = 8088
null
The token for the Event Collector
SplunkEventCollectorToken
null
The message to send to the event collector
Message
null
Script body
Steps based on this template will execute the following PowerShell script.
If ([System.Net.ServicePointManager]::CertificatePolicy -ne $null)
{
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class NoSSLCheckPolicy : ICertificatePolicy {
public NoSSLCheckPolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest wRequest, int certProb) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object NoSSLCheckPolicy
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType] "Ssl3"
# Check the parameters.
if (-NOT $SplunkHost) { throw "You must enter a value for 'Splunk Host'." }
if (-NOT $SplunkEventCollectorPort) { throw "You must enter a value for 'Splunk Event Collector Port'." }
if (-NOT $SplunkEventCollectorToken) { throw "You must enter a value for 'Event Collector Token'." }
if (-NOT $Message) { throw "You must enter a value for 'Message'." }
$properties = @{
Message = $Message;
ProjectName = $OctopusParameters['Octopus.Project.Name'];
ReleaseNumber = $OctopusParameters['Octopus.Release.Number'];
EnvironmentName = $OctopusParameters['Octopus.Environment.Name'];
DeploymentName = $OctopusParameters['Octopus.Deployment.Name'];
Channel = $OctopusParameters['Octopus.Release.Channel.Name'];
ReleaseUri = $OctopusParameters['Octopus.Web.ReleaseLink'];
DeploymentUri = $OctopusParameters['Octopus.Web.DeploymentLink'];
DeploymentCreatedBy = $OctopusParameters['Octopus.Deployment.CreatedBy.Username'];
Comments = $OctopusParameters['Octopus.Deployment.Comments'];
}
$exception = $null
if ($OctopusParameters['Octopus.Deployment.Error']) {
$properties["DeploymentError"] = $OctopusParameters['Octopus.Deployment.Error']
$properties["DeploymentDetailedError"] = $OctopusParameters['Octopus.Deployment.ErrorDetail']
}
$body = @{
event =(ConvertTo-Json $properties)
}
$uri = "https://" + $SplunkHost + ":" + $SplunkEventCollectorPort + "/services/collector"
$header = @{"Authorization"="Splunk " + $SplunkEventCollectorToken}
Invoke-RestMethod -Method Post -Uri $uri -Body (ConvertTo-Json $body) -Header $header
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": "eb2ef48d-d4d1-40c9-9dab-769c1bac7608",
"Name": "Log to a Splunk Event Collector",
"Description": "A step template that logs a given message to the Splunk [Event Collector](http://dev.splunk.com/view/event-collector/SP-CAAAE6M) along with related Octopus Deploy variables.",
"Version": 3,
"ExportedAt": "2016-05-11T06:13:32.800+00:00",
"ActionType": "Octopus.Script",
"Author": "bobjwalker",
"Parameters": [
{
"Name": "SplunkHost",
"Label": "The host endpoint of the Splunk Event Collector",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "SplunkEventCollectorPort",
"Label": "The port of the Event Collector",
"HelpText": null,
"DefaultValue": "8088",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "SplunkEventCollectorToken",
"Label": "The token for the Event Collector",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Message",
"Label": "The message to send to the event collector",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "MultiLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.ScriptBody": "If ([System.Net.ServicePointManager]::CertificatePolicy -ne $null)\n{\nadd-type @\" \n using System.Net; \n using System.Security.Cryptography.X509Certificates; \n\n public class NoSSLCheckPolicy : ICertificatePolicy { \n public NoSSLCheckPolicy() {} \n public bool CheckValidationResult( \n ServicePoint sPoint, X509Certificate cert, \n WebRequest wRequest, int certProb) { \n return true; \n } \n } \n\"@ \n[System.Net.ServicePointManager]::CertificatePolicy = new-object NoSSLCheckPolicy \n}\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType] \"Ssl3\"\n\n\n# Check the parameters.\nif (-NOT $SplunkHost) { throw \"You must enter a value for 'Splunk Host'.\" }\nif (-NOT $SplunkEventCollectorPort) { throw \"You must enter a value for 'Splunk Event Collector Port'.\" }\nif (-NOT $SplunkEventCollectorToken) { throw \"You must enter a value for 'Event Collector Token'.\" } \nif (-NOT $Message) { throw \"You must enter a value for 'Message'.\" } \n \n$properties = @{\nMessage = $Message;\nProjectName = $OctopusParameters['Octopus.Project.Name'];\nReleaseNumber = $OctopusParameters['Octopus.Release.Number']; \nEnvironmentName = $OctopusParameters['Octopus.Environment.Name'];\nDeploymentName = $OctopusParameters['Octopus.Deployment.Name'];\nChannel = $OctopusParameters['Octopus.Release.Channel.Name']; \nReleaseUri = $OctopusParameters['Octopus.Web.ReleaseLink'];\nDeploymentUri = $OctopusParameters['Octopus.Web.DeploymentLink'];\nDeploymentCreatedBy = $OctopusParameters['Octopus.Deployment.CreatedBy.Username'];\nComments = $OctopusParameters['Octopus.Deployment.Comments'];\n} \n\n$exception = $null\nif ($OctopusParameters['Octopus.Deployment.Error']) { \n $properties[\"DeploymentError\"] = $OctopusParameters['Octopus.Deployment.Error']\n $properties[\"DeploymentDetailedError\"] = $OctopusParameters['Octopus.Deployment.ErrorDetail']\n} \n\n$body = @{\n event =(ConvertTo-Json $properties)\n}\n \n$uri = \"https://\" + $SplunkHost + \":\" + $SplunkEventCollectorPort + \"/services/collector\"\n$header = @{\"Authorization\"=\"Splunk \" + $SplunkEventCollectorToken}\n\nInvoke-RestMethod -Method Post -Uri $uri -Body (ConvertTo-Json $body) -Header $header\n",
"Octopus.Action.Script.ScriptFileName": null,
"Octopus.Action.Package.NuGetFeedId": null,
"Octopus.Action.Package.NuGetPackageId": null
},
"Category": "Splunk",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/splunk-log-event-collector.json",
"Website": "/step-templates/eb2ef48d-d4d1-40c9-9dab-769c1bac7608",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD9QTFRFQUFBAAAAmpqazeXKKCgor9er////f39/arNhv7+/z8/P7+/vYGBg39/fr6+vfr12cHBw7PXrj8aJ9vr1c7hrbhrLqwAAA3RJREFUeNrs2ul2oyAYgGEkRCqItc3c/7VOXEDQaMEkZ5bz8qtiRR6WD7AV9X+SBBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQP4gpBdD6k8+LZ96+qUQUQ3pbFn6qaeBAAECBAiQ90NMp7VsNtm2kfd8cxZi7k/rzu5AzOshUlVTEt39qpl+vv8g5myl7RqyJk3XOq5uKLV1jyCyUtIbL5dXQKx/4fjSBdJH2cqUQqyIHjdbSONfN6Trx+fleUjsqJoAaaskmTKISkqt3BpiqhTykUvZh8i5yK6RouqXoTXUptfaN6y4FUFWqV1BbOIYIZmUXcitDVWo63FiNsnbw6UshQwzwPh2sAlkHnfeUV8+PnIp4oeQ2i0ZvuYivVaFEBffGJtBr55Wyzu/rrkUkb82NFEjjmmeLV0RRKelJfFsKlDZuBpf119ZlJ8gSzeHyR4yuimjL4KEWm4hczi4rQd5FmUf4jtAuTQjGmxhqBVErf3ALB/0Rz7lIPyGONslELfptMIF8TiePV7Xb9fPmfLUgtjHkPqtkP36XCbKqS1K6BNh3w9RcaM97JXP05BbFzfUmyHzHBkDcr0/T87ufv3w0vsQ9SKIHwCmPpruZ88j1g+vAGnWUas9glT5kNs8KbdxK2dZ/PkMIXz9Z4i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