From 67fb1473867f1feca5d8d8c5fc010c4298d4c640 Mon Sep 17 00:00:00 2001 From: Matthew Casperson Date: Thu, 26 Feb 2026 06:12:01 +1000 Subject: [PATCH 1/2] Update SMTP server check script to increment version and enhance error messaging for API key configuration --- step-templates/octopus-smtp-server-configured.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/step-templates/octopus-smtp-server-configured.json b/step-templates/octopus-smtp-server-configured.json index 8a81725f9..104250ef2 100644 --- a/step-templates/octopus-smtp-server-configured.json +++ b/step-templates/octopus-smtp-server-configured.json @@ -3,7 +3,7 @@ "Name": "Octopus - Check SMTP Server Configured", "Description": "Checks that the SMTP server has been configured.", "ActionType": "Octopus.Script", - "Version": 1, + "Version": 2, "CommunityActionTemplateId": null, "Packages": [], "GitDependencies": [], @@ -11,7 +11,7 @@ "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" + "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 for Argo CD instances in this space.\"\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": [ { From 2bffabcc079fda8d19825e7038bb9fb3bba3f6b2 Mon Sep 17 00:00:00 2001 From: Matthew Casperson Date: Fri, 27 Feb 2026 09:39:53 +1000 Subject: [PATCH 2/2] Update SMTP server check script to improve error messaging for API key configuration --- step-templates/octopus-smtp-server-configured.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/step-templates/octopus-smtp-server-configured.json b/step-templates/octopus-smtp-server-configured.json index 104250ef2..6b46f08f2 100644 --- a/step-templates/octopus-smtp-server-configured.json +++ b/step-templates/octopus-smtp-server-configured.json @@ -11,7 +11,7 @@ "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 for Argo CD instances in this space.\"\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" + "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": [ {