-
Notifications
You must be signed in to change notification settings - Fork 506
Expand file tree
/
Copy pathoctopus-smtp-server-configured.json
More file actions
36 lines (36 loc) · 2.62 KB
/
octopus-smtp-server-configured.json
File metadata and controls
36 lines (36 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"Id": "ad8126be-37af-4297-b46e-fce02ba3987a",
"Name": "Octopus - Check SMTP Server Configured",
"Description": "Checks that the SMTP server has been configured.",
"ActionType": "Octopus.Script",
"Version": 2,
"CommunityActionTemplateId": null,
"Packages": [],
"GitDependencies": [],
"Properties": {
"OctopusUseBundledTooling": "False",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "$apiKey = \"#{SmtpCheck.Octopus.Api.Key}\"\n$isSmtpConfigured = $false\n\nif (![string]::IsNullOrWhitespace($apiKey) -and $apiKey.StartsWith(\"API-\"))\n{\n if ([String]::IsNullOrWhitespace(\"#{Octopus.Web.ServerUri}\"))\n {\n $octopusUrl = \"#{Octopus.Web.BaseUrl}\"\n }\n else\n {\n $octopusUrl = \"#{Octopus.Web.ServerUri}\"\n }\n\n $uriBuilder = New-Object System.UriBuilder(\"$octopusUrl/api/smtpconfiguration/isconfigured\")\n $uri = $uriBuilder.ToString()\n\n try\n {\n $headers = @{ \"X-Octopus-ApiKey\" = $apiKey }\n $smtpConfigured = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers\n $isSmtpConfigured = $smtpConfigured.IsConfigured\n }\n catch\n {\n Write-Host \"Error checking SMTP configuration: $($_.Exception.Message)\"\n }\n}\nelse\n{\n Write-Highlight \"The project variable SmtpCheck.Octopus.Api.Key has not been configured, unable to check SMTP configuration.\"\n Write-Highlight \"See the [Octopus documentation](https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key) for details on creating API keys.\"\n Write-Highlight \"Once you have an API key, add it to the $($OctopusParameters['Octopus.Step.Name']) step to enable the ability to check the SMTP configuration.\"\n}\n\nif (-not $isSmtpConfigured)\n{\n Write-Highlight \"SMTP is not configured. Please [configure SMTP](https://octopus.com/docs/projects/built-in-step-templates/email-notifications#smtp-configuration) settings in Octopus Deploy.\"\n}\n\nSet-OctopusVariable -Name SmtpConfigured -Value $isSmtpConfigured"
},
"Parameters": [
{
"Id": "d48a2f7f-f895-459a-ae63-e81c8eb24d43",
"Name": "SmtpCheck.Octopus.Api.Key",
"Label": "Octopus API Key",
"HelpText": "The API key used to access the Octopus instance",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
}
],
"StepPackageId": "Octopus.Script",
"$Meta": {
"ExportedAt": "2025-10-12T23:48:48.086Z",
"OctopusVersion": "2025.3.14357",
"Type": "ActionTemplate"
},
"LastModifiedBy": "mcasperson",
"Category": "Octopus"
}