This guide explains how to configure GitLab webhooks for Git-Bridge.
Webhook setup is required when the mirror direction is target-to-source or bidirectional. If you only use source-to-target with CodeCommit as source, SQS handles event delivery automatically and no webhook is needed.
- GitLab project with Maintainer or Owner access
- Git-Bridge deployed and accessible (e.g.,
http://git-bridge.example.com) WEBHOOK_GITLAB_SECRETconfigured in K8s Secret (optional but recommended)
Navigate to your GitLab project:
Settings > Webhooks > Add new webhook
| Field | Value |
|---|---|
| URL | http://git-bridge.example.com/webhook/gitlab |
| Secret token | Value of WEBHOOK_GITLAB_SECRET (e.g., git-bridge-token) |
| Trigger | Push events |
| SSL verification | Disable (if using HTTP, not HTTPS) |
Only Push events is needed. GitLab's push event covers both branch pushes and tag pushes.
Other events (Merge request, Issue, etc.) are not processed by Git-Bridge and can be left unchecked.
- Click Add webhook
- Scroll down to the webhook list
- Click Test > Push events
- Verify the response returns HTTP 200
You can also verify by checking Git-Bridge logs:
kubectl logs -n git-bridge -l app=git-bridge -fThe secret token is used to verify that incoming webhook requests are genuinely from GitLab. This is optional but recommended for security.
- Set
WEBHOOK_GITLAB_SECRETink8s/secret.yamlto any value you choose - Use the same value in the GitLab webhook Secret token field
- If
WEBHOOK_GITLAB_SECRETis empty, Git-Bridge skips token verification
Each GitLab project that acts as a target (in target-to-source or bidirectional direction) needs its own webhook configured. The same secret token can be used across all projects.
If your configmap.yaml has:
repos:
- name: repo-a
source: codecommit
target: gitlab
target_path: server/repo-a
direction: bidirectional # webhook required
- name: repo-b
source: codecommit
target: gitlab
target_path: server/repo-b
direction: source-to-target # webhook NOT required
- name: repo-c
source: codecommit
target: gitlab
target_path: team/repo-c
direction: target-to-source # webhook requiredThen you need to configure webhooks on:
server/repo-a(bidirectional)team/repo-c(target-to-source)
No webhook is needed for server/repo-b (source-to-target).
| Symptom | Cause | Fix |
|---|---|---|
| HTTP 401 Unauthorized | Secret token mismatch | Ensure WEBHOOK_GITLAB_SECRET matches the GitLab webhook secret token |
| HTTP 405 Method Not Allowed | Wrong HTTP method | Verify webhook URL is correct and GitLab is sending POST |
| HTTP 400 Bad Request | Invalid payload | Check GitLab webhook event type is set to Push events |
| Mirror sync not triggered | Wrong direction | Verify the repo's direction is target-to-source or bidirectional |
| Mirror sync not triggered | Wrong target_path |
Ensure target_path in config matches the GitLab project's path_with_namespace |
| Push to source fails (403) | IAM permission denied | Add codecommit:GitPush to the IAM policy for the mirror user |
In GitLab, go to:
Settings > Webhooks > (your webhook) > Recent events
This shows the delivery history with request/response details for debugging.