diff --git a/step-templates/octopus-smtp-server-configured.json b/step-templates/octopus-smtp-server-configured.json index 8a81725f9..6b46f08f2 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 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": [ {