Sentry Release Tracking (Token Auth)

Octopus.Script exported 2021-09-10 by shout belongs to ‘Sentry’ category.

Posts a new release to Sentry and links it to one or more sentry projects.

Updated version which uses the newer API Token instead of the now depreciated API Key which is only available in legacy Sentry accounts.

Parameters

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

Organisation Slug

SentryReleaseTracking.organization =

The organisation-name part of the url

Project Slug

SentryReleaseTracking.projects =

;-separated list of all your sentry api slugs for the apps, (web/api/admin) on this specific Environment.

myapp-web-dev;myapp-api-dev

protip: Add them all to a environment-scoped variable.

Sentry token

SentryReleaseTracking.apiToken =

Your sentry token

Script body

Steps based on this template will execute the following PowerShell script.

$organization = $OctopusParameters["SentryReleaseTracking.organization"]
$projects = $OctopusParameters["SentryReleaseTracking.projects"]
$apiToken = $OctopusParameters["SentryReleaseTracking.apiToken"]

$url = "https://sentry.io/api/0/organizations/$organization/releases/"
Write-Host $url

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer $apiToken")
$body = ConvertTo-Json @{ 
	"version" = $OctopusParameters['Octopus.Release.Number']
    "projects" = $projects.Split(";")
}

Write-Host $body
Try
{
	$response = Invoke-RestMethod -Method Post -Uri "$url" -Body $body -Headers $headers -ContentType "application/json"
	Write-Host $response
}
Catch { 
	if($_.Exception.Response.StatusCode -ne 400)
	{
  		Throw $_
    }
}

Provided under the Apache License version 2.0.

Report an issue

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

{
  "Id": "f957377a-6389-4ed1-87a6-3317e5676a77",
  "Name": "Sentry Release Tracking (Token Auth)",
  "Description": "Posts a new release to Sentry and links it to one or more sentry projects. \n\n**Updated version** which uses the newer **API Token** instead of the now depreciated API Key which is only available in legacy Sentry accounts.",
  "Version": 1,
  "ExportedAt": "2021-09-10T12:19:29.946Z",
  "ActionType": "Octopus.Script",
  "Author": "shout",
  "Packages": [],
  "Parameters": [
    {
      "Id": "84a0e54c-c914-481a-9277-4b9ab176c9d6",
      "Name": "SentryReleaseTracking.organization",
      "Label": "Organisation Slug",
      "HelpText": "The organisation-name part of the url",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "7ae25fac-65b3-4830-9ade-56c3443ac63b",
      "Name": "SentryReleaseTracking.projects",
      "Label": "Project Slug",
      "HelpText": "`;`-separated list of all your sentry api slugs for the apps, (web/api/admin) on this specific Environment.\n\n    myapp-web-dev;myapp-api-dev\n\nprotip: Add them all to a environment-scoped variable.",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Id": "4d2396cc-5313-4188-91ab-18cf7b59369a",
      "Name": "SentryReleaseTracking.apiToken",
      "Label": "Sentry token",
      "HelpText": "Your sentry token",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "$organization = $OctopusParameters[\"SentryReleaseTracking.organization\"]\n$projects = $OctopusParameters[\"SentryReleaseTracking.projects\"]\n$apiToken = $OctopusParameters[\"SentryReleaseTracking.apiToken\"]\n\n$url = \"https://sentry.io/api/0/organizations/$organization/releases/\"\nWrite-Host $url\n\n$headers = New-Object \"System.Collections.Generic.Dictionary[[String],[String]]\"\n$headers.Add(\"Authorization\", \"Bearer $apiToken\")\n$body = ConvertTo-Json @{ \n\t\"version\" = $OctopusParameters['Octopus.Release.Number']\n    \"projects\" = $projects.Split(\";\")\n}\n\nWrite-Host $body\nTry\n{\n\t$response = Invoke-RestMethod -Method Post -Uri \"$url\" -Body $body -Headers $headers -ContentType \"application/json\"\n\tWrite-Host $response\n}\nCatch { \n\tif($_.Exception.Response.StatusCode -ne 400)\n\t{\n  \t\tThrow $_\n    }\n}\n",
    "Octopus.Action.Script.ScriptSource": "Inline"
  },
  "Category": "Sentry",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/sentry-release-tracking-token-auth.json",
  "Website": "/step-templates/f957377a-6389-4ed1-87a6-3317e5676a77",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAC7BJREFUeNrsnetVW8kShYWW/0sZoAyQI0COwGSAM4AMwBGYDKSJwMoAiAAUgSECQwRMLZhhMIhh16NPv/b+cde964rjo+7v1KurjnYeHh5GFBWtMZeAIlgUwaIIFkURLIpgUQSLoggWRbAogkVRBIsiWBTBoiiCRREsimBRFMGiCBZFsCiKYFEEiyJYFEWwKIJFESyKIlgUwaIIFkWZ9YlL8KHu7u6ur6+f/+d8Pp9Op1wWgmXUxcXFarWS/7y9vX31f00mk4N/xYXargfqjc7Pz3d3d5HVk48tl0uu2FsRrD/0+/fvw8ND7cO5v78vf8jVe6kdvnjtZSy1WCw2m43hb/f29sRvSvjFZXwSwQqg6tktSozPuJ7lhj8kYbiHKpHE+IImV5Jg/aezs7PLy0v/dQTN09NTridd4T9OcDab3d/fh1xtMpnc3NzQIdJijcTGRFElkksdHx9zVXu3WBJuf/78OfyyV1dXnWeIvVusRNaFRqtrsNbrdUjM/lZy2dVq1TVZPVeHwXOb0WP98/z8XBwcXpeXi/dcju8XrJOTEzzRe4mIQAb+ofwTBKu7M0HBBeTj1TGzmC6cyF+/fhGsjoR7NLFPb//869ev4J/LJwlWR10xeAwqH357BbFDzisQrAa1v7/vtzd4iLbV5hGs1iQBU0iEJFEanlR22AzYF1gqGj7M6VSM9lZ66Ass3H+BVSjcq/ZWeugILFXEDTovVR7QVemhI7DwGoHYoRSVC9VlCVaDJYarqyuVIcRrrf2UHnoBCz+HEQuUNHQjWJ2WGGzpG55s/vjxg2A1UmLAXZU5d/v58ydLD32BdXR0NIyfwksPcksEq6MSgzOylpA/UX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KPC8+UwzvTc/Uuh4GlGqGMfS7BtVMtHPh1cA6yxO8ZSw+jqLvPePyZ4owPvKbqu+Q6ZskyNj0a2N4mqpqAnkv1RCIPusqnI6FColL4AK9NjAdLNd2WqM4LPpQqe4DAqmpsQi4YnhhqSw9RCUQAWCWcTIFteqptA81wxgsmqgSFuOOAr4Gbq6SvIAe9If44gk85Hr+DZjXRKuGOJSTSGo98Wq/X9/f34HMwn89HyXRwcIB87OLiArzgbDZDPnZ3d5frgirJv358fIx8UjYUX6X35AULvAN5CM7OzkYptVgskI9dX1/HchB+wZubm0RLdHp6Cibv+cECl1W+0nQ6TQqWbBuyajgHT0FhIAfZwRKBj7dqlZKAhdht2W/QCDuFuFrVkiEPQ1IOUgQMyNPid8desDabzYef+fbt2zCrhoAFRoT4BVV7gGyq31r4YwZkW9OChXgfv8OODbNi78e/B8ME76qv73w3rOiTP7K5vb39/89cXl6K0ZIwCwwyPDcTTur3799Ldm3ah0SyeNmOAVYyACzkRv96VDmbAdo2UDs7O7m+y5cvX8p8RMf+Z3pEhUqVDThfl59uWwnWoL4V0YehxTDJY2awZOk9P16SReG18sZ0eHjoLzqO/fcxTI0qUKnz+dolaZb/IgFgiTeszmhR7+no6CjETo9D7ma1Wnl+toQqRLu7uyHmKgwsccmSw5OtqiXbt16vo450x1G3NZ/PyVbVVMn2BfY1jQNv7okt2+/hUBklWyYJTWy33Dj2FuXm5BZPTk5oumoJqpbLpWxZfGElXRO63LFkiwUSpmq9z3KHqW9PNuXppcPpOsV3Bli7m0eVA5bEp7jZH6w141UFJ93tDXNYspProaTa1phLQBEsimBRBIuiCBZFsCiCRVEEiyJYFMGiKIJFESyKYFEUwaIIFkWwKIpgUQSLIlgURbAogkURLIoiWBTBoggWRREsimBRBIuizPpbgAEAb8EveUcuJcMAAAAASUVORK5CYII=",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Friday, September 10, 2021