diff --git a/step-templates/octopus-smtp-server-configured.json b/step-templates/octopus-smtp-server-configured.json new file mode 100644 index 000000000..8a81725f9 --- /dev/null +++ b/step-templates/octopus-smtp-server-configured.json @@ -0,0 +1,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": 1, + "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}\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" +}