Loading...
Loading...
GitLab webhook operations via API. ALWAYS use this skill when user wants to: (1) list/view webhooks, (2) create/update/delete webhooks, (3) configure webhook events, (4) test webhook delivery.
npx skill4agent add grandcamel/gitlab-assistant-skills gitlab-webhookglab api| Operation | Command Pattern | Risk |
|---|---|---|
| List webhooks | | - |
| Get webhook | | - |
| Create webhook | | ⚠️ |
| Update webhook | | ⚠️ |
| Delete webhook | | ⚠️⚠️ |
| Test webhook | | ⚠️ |
| List group hooks | | - |
api| Event | Flag | Description |
|---|---|---|
| Push | | Code pushed to repository |
| Tag | | Tags created/deleted |
| Merge Request | | MR created/updated/merged |
| Issues | | Issue created/updated/closed |
| Notes | | Comments on MRs/issues/commits |
| Confidential Notes | | Confidential comments |
| Job | | CI job status changes |
| Pipeline | | Pipeline status changes |
| Deployment | | Deployment status changes |
| Wiki | | Wiki pages created/updated |
| Releases | | Releases created |
# List project webhooks
glab api projects/123/hooks --method GET
# List with pagination
glab api projects/123/hooks --paginate
# List group webhooks (Premium)
glab api groups/456/hooks --method GET
# Using project path
glab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/hooks"# Get specific webhook
glab api projects/123/hooks/789 --method GET# Basic webhook for push events
glab api projects/123/hooks --method POST \
-f url="https://example.com/webhook" \
-f push_events=true
# Webhook for MR and pipeline events
glab api projects/123/hooks --method POST \
-f url="https://example.com/webhook" \
-f push_events=false \
-f merge_requests_events=true \
-f pipeline_events=true
# Webhook with secret token
glab api projects/123/hooks --method POST \
-f url="https://example.com/webhook" \
-f push_events=true \
-f token="my-secret-token" \
-f enable_ssl_verification=true
# Full-featured webhook
glab api projects/123/hooks --method POST \
-f url="https://example.com/webhook" \
-f push_events=true \
-f tag_push_events=true \
-f merge_requests_events=true \
-f issues_events=true \
-f note_events=true \
-f pipeline_events=true \
-f job_events=true \
-f token="secret" \
-f enable_ssl_verification=true
# Webhook for specific branches only
glab api projects/123/hooks --method POST \
-f url="https://example.com/webhook" \
-f push_events=true \
-f push_events_branch_filter="main"# Update URL
glab api projects/123/hooks/789 --method PUT \
-f url="https://new-url.com/webhook"
# Enable additional events
glab api projects/123/hooks/789 --method PUT \
-f pipeline_events=true \
-f job_events=true
# Disable event
glab api projects/123/hooks/789 --method PUT \
-f push_events=false
# Update secret token
glab api projects/123/hooks/789 --method PUT \
-f token="new-secret-token"
# Change SSL verification
glab api projects/123/hooks/789 --method PUT \
-f enable_ssl_verification=false# Delete webhook
glab api projects/123/hooks/789 --method DELETE# Test push event
glab api projects/123/hooks/789/test/push_events --method POST
# Test MR event
glab api projects/123/hooks/789/test/merge_requests_events --method POST
# Test tag push event
glab api projects/123/hooks/789/test/tag_push_events --method POST
# Test note event
glab api projects/123/hooks/789/test/note_events --method POST
# Test issues event
glab api projects/123/hooks/789/test/issues_events --method POST| Option | Type | Description |
|---|---|---|
| string | Webhook endpoint URL (required) |
| string | Secret token for validation |
| boolean | Trigger on push |
| string | Branch filter for push events |
| boolean | Trigger on tag push |
| boolean | Trigger on MR events |
| boolean | Trigger on issue events |
| boolean | Trigger on confidential issues |
| boolean | Trigger on comments |
| boolean | Trigger on confidential notes |
| boolean | Trigger on pipeline events |
| boolean | Trigger on job events |
| boolean | Trigger on deployments |
| boolean | Trigger on wiki changes |
| boolean | Trigger on releases |
| boolean | Verify SSL certificate |
# Create webhook for Slack
glab api projects/123/hooks --method POST \
-f url="https://hooks.slack.com/services/T00/B00/XXX" \
-f push_events=true \
-f merge_requests_events=true \
-f pipeline_events=true \
-f enable_ssl_verification=true# Webhook to trigger external CI
glab api projects/123/hooks --method POST \
-f url="https://ci.example.com/trigger" \
-f push_events=true \
-f tag_push_events=true \
-f token="ci-trigger-token" \
-f push_events_branch_filter="main"# List all webhooks with details
glab api projects/123/hooks --paginate | \
jq -r '.[] | "ID: \(.id)\n URL: \(.url)\n Events: push=\(.push_events), mr=\(.merge_requests_events), pipeline=\(.pipeline_events)\n SSL: \(.enable_ssl_verification)\n"'# 1. Get current webhook config
glab api projects/123/hooks/789 | jq
# 2. Update URL
glab api projects/123/hooks/789 --method PUT \
-f url="https://new-service.example.com/webhook"
# 3. Test the webhook
glab api projects/123/hooks/789/test/push_events --method POST# Webhook for deployment events only
glab api projects/123/hooks --method POST \
-f url="https://deploy-tracker.example.com/webhook" \
-f push_events=false \
-f deployment_events=true \
-f token="deploy-secret"hook_id=789
# Keep only push and MR events
glab api projects/123/hooks/$hook_id --method PUT \
-f push_events=true \
-f merge_requests_events=true \
-f tag_push_events=false \
-f issues_events=false \
-f note_events=false \
-f job_events=false \
-f pipeline_events=false{
"object_kind": "push",
"ref": "refs/heads/main",
"before": "abc123...",
"after": "def456...",
"commits": [...],
"project": {...}
}{
"object_kind": "merge_request",
"event_type": "merge_request",
"object_attributes": {
"iid": 1,
"title": "...",
"state": "opened",
"action": "open"
}
}# In your webhook handler, verify the X-Gitlab-Token header
# matches the token you configured| Issue | Cause | Solution |
|---|---|---|
| Webhook not firing | Event not enabled | Check event flags |
| 403 Forbidden | Not maintainer | Need Maintainer+ role |
| SSL verification failed | Invalid certificate | Use |
| Webhook URL unreachable | Network/firewall issue | Verify URL is accessible from GitLab |
| Test returns error | Endpoint error | Check your webhook handler logs |
| Too many requests | Webhook loop | Verify handler doesn't trigger events |