Sentry Release Tracking

Octopus.Script exported 2015-11-27 by bobjwalker belongs to ‘Sentry’ category.

Posts a new release to Sentry, It can optionaly resolve all previous issues.

If the release already exists, it only applies the resolving.

Parameters

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

Organisation Slug

organization =

The organisation-name part of the url

Project Slug

projects

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

myapp-web-dev;myapp-api-dev

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

Resolve all open issues

resolveIssues = false

Sentry api key

sentryApiKey =

Your sentry api key

Script body

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

$token  = [System.Text.Encoding]::UTF8.GetBytes($sentryApiKey+":")
$base64Token = [System.Convert]::ToBase64String($token)

Write-Host $base64Token

ForEach ($project in $projects.Split(';'))  
{
    $url = "https://app.getsentry.com/api/0/projects/$organization/$project/releases/"
    Write-Host $url
    
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Authorization", "Basic $base64Token")
    
    $body = @{ "version" = $OctopusParameters['Octopus.Release.Number'] }
    
    $body = ConvertTo-Json $body
    
    Write-Host $body
    Try
    {
        $response = Invoke-RestMethod -Method Post -Uri "$url" -Body $body -Headers $headers -ContentType "application/json"
        Write-Host $response
    }
    Catch [System.Net.WebException] 
    {
        Write-Host $_
        if($_.Exception.Response.StatusCode.Value__ -ne 400)
        {
            Throw
        }
    }
    if ($resolveIssues)
    {
        $resolveBody = '{"status":"resolved"}'
        Write-Host $resolveBody
        $url = "https://app.getsentry.com/api/0/projects/$organization/$project/groups/"
        Write-Host $url
        $response = Invoke-RestMethod -Method Put -Uri "$url" -Body $resolveBody -Headers $headers -ContentType "application/json"
        Write-Host $response
    }
}

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": "ee62b8ac-2731-4147-8cb4-ceda0abe5a80",
  "Name": "Sentry Release Tracking",
  "Description": "Posts a new release to Sentry, It can optionaly resolve all previous issues.\n\nIf the release already exists, it only applies the resolving.",
  "Version": 47,
  "ExportedAt": "2015-11-27T12:26:31.568+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "organization",
      "Label": "Organisation Slug",
      "HelpText": "The organisation-name part of the url",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "projects",
      "Label": "Project Slug",
      "HelpText": "`;`-separated list of all your sentry api slugs for the apps, (web/api/admin) on this spesific Environment.\n\n    myapp-web-dev;myapp-api-dev\n\nprotip: Add them all to a environment-scoped variable.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "resolveIssues",
      "Label": "Resolve all open issues",
      "HelpText": "",
      "DefaultValue": "false",
      "DisplaySettings": {
        "Octopus.ControlType": "Checkbox"
      }
    },
    {
      "Name": "sentryApiKey",
      "Label": "Sentry api key",
      "HelpText": "Your sentry api key",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "$token  = [System.Text.Encoding]::UTF8.GetBytes($sentryApiKey+\":\")\n$base64Token = [System.Convert]::ToBase64String($token)\n\nWrite-Host $base64Token\n\nForEach ($project in $projects.Split(';'))  \n{\n    $url = \"https://app.getsentry.com/api/0/projects/$organization/$project/releases/\"\n    Write-Host $url\n    \n    $headers = New-Object \"System.Collections.Generic.Dictionary[[String],[String]]\"\n    $headers.Add(\"Authorization\", \"Basic $base64Token\")\n    \n    $body = @{ \"version\" = $OctopusParameters['Octopus.Release.Number'] }\n    \n    $body = ConvertTo-Json $body\n    \n    Write-Host $body\n    Try\n    {\n        $response = Invoke-RestMethod -Method Post -Uri \"$url\" -Body $body -Headers $headers -ContentType \"application/json\"\n        Write-Host $response\n    }\n    Catch [System.Net.WebException] \n    {\n        Write-Host $_\n        if($_.Exception.Response.StatusCode.Value__ -ne 400)\n        {\n            Throw\n        }\n    }\n    if ($resolveIssues)\n    {\n        $resolveBody = '{\"status\":\"resolved\"}'\n        Write-Host $resolveBody\n        $url = \"https://app.getsentry.com/api/0/projects/$organization/$project/groups/\"\n        Write-Host $url\n        $response = Invoke-RestMethod -Method Put -Uri \"$url\" -Body $resolveBody -Headers $headers -ContentType \"application/json\"\n        Write-Host $response\n    }\n}"
  },
  "Category": "Sentry",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/sentry-release-tracking.json",
  "Website": "/step-templates/ee62b8ac-2731-4147-8cb4-ceda0abe5a80",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAC7BJREFUeNrsnetVW8kShYWW/0sZoAyQI0COwGSAM4AMwBGYDKSJwMoAiAAUgSECQwRMLZhhMIhh16NPv/b+cde964rjo+7v1KurjnYeHh5GFBWtMZeAIlgUwaIIFkURLIpgUQSLoggWRbAogkVRBIsiWBTBoiiCRREsimBRFMGiCBZFsCiKYFEEiyJYFEWwKIJFESyKIlgUwaIIFkWZ9YlL8KHu7u6ur6+f/+d8Pp9Op1wWgmXUxcXFarWS/7y9vX31f00mk4N/xYXargfqjc7Pz3d3d5HVk48tl0uu2FsRrD/0+/fvw8ND7cO5v78vf8jVe6kdvnjtZSy1WCw2m43hb/f29sRvSvjFZXwSwQqg6tktSozPuJ7lhj8kYbiHKpHE+IImV5Jg/aezs7PLy0v/dQTN09NTridd4T9OcDab3d/fh1xtMpnc3NzQIdJijcTGRFElkksdHx9zVXu3WBJuf/78OfyyV1dXnWeIvVusRNaFRqtrsNbrdUjM/lZy2dVq1TVZPVeHwXOb0WP98/z8XBwcXpeXi/dcju8XrJOTEzzRe4mIQAb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wUSpmq9z3KHqW9PNuXppcPpOsV3Bli7m0eVA5bEp7jZH6w141UFJ93tDXNYspProaTa1phLQBEsimBRBIuiCBZFsCiCRVEEiyJYFMGiKIJFESyKYFEUwaIIFkWwKIpgUQSLIlgURbAogkURLIoiWBTBoggWRREsimBRBIuizPpbgAEAb8EveUcuJcMAAAAASUVORK5CYII=",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Friday, November 27, 2015