Skip to content

Add escalation-related attributes to issue webhook

Sarah Yasonik requested to merge sy-webhooks-for-incident-escalations into master

What does this MR do and why?

This MR adds support for escalation_status and escalation_policy attributes to the issue webhook payload.

Both fields correspond to incident-only features, so they'll only appear in the webhook payload for incidents. escalation_policy is only available for GitLab Premium, so the field will only appear correspondingly.

As this is still behind the incident_escalations feature flag, I've opted to exclude a changelog. If the incident_escalations flag is rolled out before this merges, I'll add the changelog trailers then.

Relevant sample hook output

Updating status Updating policy Updating status & policy Updating unrelated field (milestone)
Screen_Shot_2022-02-10_at_7.28.14_PM Screen_Shot_2022-02-10_at_7.31.32_PM Screen_Shot_2022-02-10_at_7.30.12_PM Screen_Shot_2022-02-10_at_7.24.55_PM

How to set up and validate locally

  1. Enable the feature flag
    Feature.enable(:incident_escalations)
  2. Create or navigate to a GitLab Premium project
  3. Create a new incident (New Issue w/ type=Incident || Monitor > Incidents)
  4. If not yet created, create an escalation policy under Monitor > Escalation Policies (any rules are fine)
  5. Setup a webhook which pushes Issues events at Settings > Webhooks
    • Possible pre-req: Setup a webhook receiver to view output (I can't remember if this is required for initial setup...)
    • Navigate to the Edit page of the hook to view hook output
  6. Update the status of the incident in the rails console (dropdown coming in !66165 (merged)) & view the hook output
    project = Project.find(<PROJECT_ID>)
    incident = project.issues.last
    ::Issues::UpdateService.new(project: project, current_user: User.first, params: { escalation_status: { status: :acknowledged } }).execute(incident)
    • escalation_status should be an attribute in the body with value of Acknowledged
    • escalation_policy should be an attribute in the body with value of nil
    • escalation_status should be present in the changes section of the payload
  7. Update the policy of the incident in the rails console (dropdown coming in !66165 (merged)) & view the hook output
    project = Project.find(<PROJECT_ID>)
    incident = project.issues.last
    policy = project.incident_management_escalation_policies.last
    ::Issues::UpdateService.new(project: project, current_user: User.first, params: { escalation_status: { policy: policy } }).execute(incident)
    • escalation_status should be an attribute in the body with value of Triggered (setting a policy re-triggers an incident)
    • escalation_policy should be an attribute in the body with value of { id: <ID>, name: <name> }
    • escalation_status & escalation_policy should both be present in the changes section of the payload
  8. Unset the policy & view the hook output
    project = Project.find(<PROJECT_ID>)
    incident = project.issues.last
    ::Issues::UpdateService.new(project: project, current_user: User.first, params: { escalation_status: { policy: nil } }).execute(incident)
    • only escalation_policy should be present in the changes section of the payload
  9. Change some other attribute via the UI to see a payload without escalation fields

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah Yasonik

Merge request reports

Loading