Skip to main content
The Gitlab plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • issue (issue)
  • mergeRequest (mergeRequest)
  • note (note)
  • pipeline (pipeline)
  • push (push)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Issue

Issue

issue An issue event from GitLab (open, update, close) Payload
NameTypeRequiredDescription
object_kindissueYes
event_typestringNo
userobjectNo
projectobjectNo
object_attributesobjectNo
{
  id?: number,
  name?: string,
  username?: string,
  avatar_url?: string
}
{
  id?: number,
  name?: string,
  web_url?: string,
  path_with_namespace?: string
}
{
  id?: number,
  iid?: number,
  title?: string,
  state?: string,
  action?: string,
  url?: string,
  description?: string | null,
  confidential?: boolean
}
{
  object_kind: issue,
  event_type?: string,
  user?: {
    id?: number,
    name?: string,
    username?: string,
    avatar_url?: string
  },
  project?: {
    id?: number,
    name?: string,
    web_url?: string,
    path_with_namespace?: string
  },
  object_attributes?: {
    id?: number,
    iid?: number,
    title?: string,
    state?: string,
    action?: string,
    url?: string,
    description?: string | null,
    confidential?: boolean
  }
}
webhookHooks example
gitlab({
    webhookHooks: {
        issue: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})

Merge Request

Merge Request

mergeRequest A merge request event from GitLab (open, update, merge, close) Payload
NameTypeRequiredDescription
object_kindmerge_requestYes
event_typestringNo
userobjectNo
projectobjectNo
object_attributesobjectNo
{
  id?: number,
  name?: string,
  username?: string,
  avatar_url?: string
}
{
  id?: number,
  name?: string,
  web_url?: string,
  path_with_namespace?: string
}
{
  id?: number,
  iid?: number,
  title?: string,
  state?: string,
  source_branch?: string,
  target_branch?: string,
  action?: string,
  url?: string,
  description?: string | null,
  merge_status?: string,
  draft?: boolean
}
{
  object_kind: merge_request,
  event_type?: string,
  user?: {
    id?: number,
    name?: string,
    username?: string,
    avatar_url?: string
  },
  project?: {
    id?: number,
    name?: string,
    web_url?: string,
    path_with_namespace?: string
  },
  object_attributes?: {
    id?: number,
    iid?: number,
    title?: string,
    state?: string,
    source_branch?: string,
    target_branch?: string,
    action?: string,
    url?: string,
    description?: string | null,
    merge_status?: string,
    draft?: boolean
  }
}
webhookHooks example
gitlab({
    webhookHooks: {
        mergeRequest: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})

Note

Note

note A comment event from GitLab (new comments on issues, MRs, commits) Payload
NameTypeRequiredDescription
object_kindnoteYes
event_typestringNo
userobjectNo
projectobjectNo
object_attributesobjectNo
issueobjectNo
merge_requestobjectNo
commitobjectNo
{
  id?: number,
  name?: string,
  username?: string,
  avatar_url?: string
}
{
  id?: number,
  name?: string,
  web_url?: string,
  path_with_namespace?: string
}
{
  id?: number,
  note?: string,
  noteable_type?: string,
  noteable_id?: number,
  url?: string,
  action?: string
}
{
  id?: number,
  iid?: number,
  title?: string
}
{
  id?: number,
  iid?: number,
  title?: string
}
{
  id?: string,
  message?: string
}
{
  object_kind: note,
  event_type?: string,
  user?: {
    id?: number,
    name?: string,
    username?: string,
    avatar_url?: string
  },
  project?: {
    id?: number,
    name?: string,
    web_url?: string,
    path_with_namespace?: string
  },
  object_attributes?: {
    id?: number,
    note?: string,
    noteable_type?: string,
    noteable_id?: number,
    url?: string,
    action?: string
  },
  issue?: {
    id?: number,
    iid?: number,
    title?: string
  },
  merge_request?: {
    id?: number,
    iid?: number,
    title?: string
  },
  commit?: {
    id?: string,
    message?: string
  }
}
webhookHooks example
gitlab({
    webhookHooks: {
        note: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})

Pipeline

Pipeline

pipeline A pipeline event from GitLab (status change) Payload
NameTypeRequiredDescription
object_kindpipelineYes
object_attributesobjectNo
userobjectNo
projectobjectNo
buildsobject[]No
{
  id?: number,
  iid?: number,
  ref?: string,
  status?: string,
  source?: string,
  created_at?: string,
  finished_at?: string | null,
  duration?: number | null
}
{
  id?: number,
  name?: string,
  username?: string,
  avatar_url?: string
}
{
  id?: number,
  name?: string,
  web_url?: string,
  path_with_namespace?: string
}
{
  id?: number,
  stage?: string,
  name?: string,
  status?: string
}[]
{
  object_kind: pipeline,
  object_attributes?: {
    id?: number,
    iid?: number,
    ref?: string,
    status?: string,
    source?: string,
    created_at?: string,
    finished_at?: string | null,
    duration?: number | null
  },
  user?: {
    id?: number,
    name?: string,
    username?: string,
    avatar_url?: string
  },
  project?: {
    id?: number,
    name?: string,
    web_url?: string,
    path_with_namespace?: string
  },
  builds?: {
    id?: number,
    stage?: string,
    name?: string,
    status?: string
  }[]
}
webhookHooks example
gitlab({
    webhookHooks: {
        pipeline: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})

Push

Push

push A push event from GitLab (git push to repository) Payload
NameTypeRequiredDescription
object_kindpushYes
event_namestringNo
beforestringNo
afterstringNo
refstringNo
checkout_shastringNo
user_idnumberNo
user_namestringNo
user_usernamestringNo
user_avatarstringNo
project_idnumberNo
projectobjectNo
commitsobject[]No
total_commits_countnumberNo
{
  id?: number,
  name?: string,
  web_url?: string,
  path_with_namespace?: string,
  default_branch?: string
}
{
  id: string,
  message?: string,
  title?: string,
  timestamp?: string,
  url?: string,
  author?: {
    name?: string,
    email?: string
  },
  added?: string[],
  modified?: string[],
  removed?: string[]
}[]
{
  object_kind: push,
  event_name?: string,
  before?: string,
  after?: string,
  ref?: string,
  checkout_sha?: string | null,
  user_id?: number,
  user_name?: string,
  user_username?: string,
  user_avatar?: string,
  project_id?: number,
  project?: {
    id?: number,
    name?: string,
    web_url?: string,
    path_with_namespace?: string,
    default_branch?: string
  },
  commits?: {
    id: string,
    message?: string,
    title?: string,
    timestamp?: string,
    url?: string,
    author?: {
      name?: string,
      email?: string
    },
    added?: string[],
    modified?: string[],
    removed?: string[]
  }[],
  total_commits_count?: number
}
webhookHooks example
gitlab({
    webhookHooks: {
        push: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})