Octopus - Check for Argo CD Instances

Octopus.Script exported 11/05/2025 by mcasperson belongs to 'Octopus' category.

Checks to see if there are any Argo CD instances registered to the space.

Parameters

When steps based on the template are included in a project's deployment process, the parameters below can be set.

Octopus Deploy API Key

Template.Octopus.API.Key

The Octopus Deploy API Key to use when making calls to the Octopus API.

Script body

Steps based on this template will execute the following PowerShell script.
Show script
# Fix ANSI Color on PWSH Core issues when displaying objects
if ($PSEdition -eq "Core") {
    $PSStyle.OutputRendering = "PlainText"
}

# Define variables
$isArgoPresent = $false

# Check to see if the Octopus.Web.ServerUri variable has a value
if (![string]::IsNullOrWhitespace($OctopusParameters["Octopus.Web.ServerUri"]))
{
    $baseUrl = $OctopusParameters["Octopus.Web.ServerUri"]
}
else
{
    $baseUrl = $OctopusParameters["Octopus.Web.BaseUrl"]
}

# Validate parameters
if ([string]::IsNullOrWhitespace($OctopusParameters["Template.Octopus.API.Key"]) -or -not $OctopusParameters["Template.Octopus.API.Key"].StartsWith("API-"))
{
    Write-Highlight "An API Key was not provided, unable to check to see if there are any Argo CD instances registered in this space."
    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."
    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."
}
else
{
    $header = @{ "X-Octopus-ApiKey" = $OctopusParameters["Template.Octopus.API.Key"] }

    # Get registered Argo CD instances
    $argoInstances = Invoke-RestMethod -Method Get -Uri "$($baseUrl)/api/#{Octopus.Space.Id}/argocdinstances/summaries" -Headers $header

    # Check the returned values
    if ($argoInstances.Resources.Count -gt 0)
    {
        Write-Highlight "Found $($argoInstances.Resources.Count) Argo instance(s) registered!"
        $isArgoPresent = $true
    }
    else
    {
        Write-Highlight "No Argo CD instances registered to space $($OctopusParameters['Octopus.Space.Name']).  Please [register an Argo CD instance](https://octopus.com/docs/argo-cd/instances) with this space."
    }
}

# Set output variable
Set-OctopusVariable -Name ArgoPresent -Value $isArgoPresent

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

Show JSON
{
  "Id": "7da3a76e-57ca-4542-846a-73c00252206c",
  "Name": "Octopus - Check for Argo CD Instances",
  "Description": "Checks to see if there are any Argo CD instances registered to the space.",
  "Version": 3,
  "ExportedAt": "2025-11-05T23:41:23.320Z",
  "ActionType": "Octopus.Script",
  "Author": "mcasperson",
  "Packages": [],
  "Parameters": [
    {
      "Id": "dfeca839-7c5d-4d5f-a941-27522f918a67",
      "Name": "Template.Octopus.API.Key",
      "Label": "Octopus Deploy API Key",
      "HelpText": "The Octopus Deploy API Key to use when making calls to the Octopus API.",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n    $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Define variables\n$isArgoPresent = $false\n\n# Check to see if the Octopus.Web.ServerUri variable has a value\nif (![string]::IsNullOrWhitespace($OctopusParameters[\"Octopus.Web.ServerUri\"]))\n{\n    $baseUrl = $OctopusParameters[\"Octopus.Web.ServerUri\"]\n}\nelse\n{\n    $baseUrl = $OctopusParameters[\"Octopus.Web.BaseUrl\"]\n}\n\n# Validate parameters\nif ([string]::IsNullOrWhitespace($OctopusParameters[\"Template.Octopus.API.Key\"]) -or -not $OctopusParameters[\"Template.Octopus.API.Key\"].StartsWith(\"API-\"))\n{\n    Write-Highlight \"An API Key was not provided, unable to check to see if there are any Argo CD instances registered in this space.\"\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}\nelse\n{\n    $header = @{ \"X-Octopus-ApiKey\" = $OctopusParameters[\"Template.Octopus.API.Key\"] }\n\n    # Get registered Argo CD instances\n    $argoInstances = Invoke-RestMethod -Method Get -Uri \"$($baseUrl)/api/#{Octopus.Space.Id}/argocdinstances/summaries\" -Headers $header\n\n    # Check the returned values\n    if ($argoInstances.Resources.Count -gt 0)\n    {\n        Write-Highlight \"Found $($argoInstances.Resources.Count) Argo instance(s) registered!\"\n        $isArgoPresent = $true\n    }\n    else\n    {\n        Write-Highlight \"No Argo CD instances registered to space $($OctopusParameters['Octopus.Space.Name']).  Please [register an Argo CD instance](https://octopus.com/docs/argo-cd/instances) with this space.\"\n    }\n}\n\n# Set output variable\nSet-OctopusVariable -Name ArgoPresent -Value $isArgoPresent"
  },
  "Category": "Octopus",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates/octopus-check-for-argo-instance.json",
  "Website": "/step-templates/7da3a76e-57ca-4542-846a-73c00252206c",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAC1QTFRFT6Tl////L5Pg8vj9Y67omsvwPJrisdfzfbzs5fL7y+T32Ov5isLucLXqvt31CJPHWwAABMJJREFUeNrs3deW4jAMAFDF3U75/89dlp0ZhiU4blJEjvQ8hYubLJsA00UCBCIQgQhEIAIRiEAEIhCBCEQgAhGIQAQiEIEIhD8kJm+t+QprfdKfB9HbYpx6CWfspj8HMi+gMgHL/AmQA8W3JTKH+ALFvzCeL0RbpyoCPE9IJeNOSQwh5Z3qd6yRGWQ2qi2cZQWxqj1WzQYSjeoJmJlAklOd4VlArOqPhQEkqBERToeMcfRJBkC0Uep8CfBpjz4JsHJ0zF3dkEWNje0kiB/sUC6eApndaIiCMyAa1PiwJ0AWhRGJHJJQHG2dC7h1rNbO1QOxSA7lNCkkKrQIpJCAB1GREILYIC1NAiwbpKF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