This guide covers:
- Tooling prerequisites
- Environment configuration
- Build and process management
- GitLab webhook setup (manual and scripted)
- Post-deploy verification
Install these tools on the host:
bun(runtime + package manager)gitpm2(process manager; installed from project dependencies)glab(GitLab CLI, authenticated)
Agent CLIs you plan to run:
claudecodexgemini
Authenticate glab before running webhook automation:
glab auth loginCreate .env from .env.example and fill all required values:
cp .env.example .envRequired keys:
GITLAB_WEBHOOK_SECRETBOT_USERNAMEGITLAB_TOKENGITLAB_HOST
Recommended for production:
DATABASE_PATH=./data/gitlab-agent-webhook.dbLOG_LEVEL=info(orwarnin noisier environments)- Concurrency keys:
CLAUDE_CONCURRENCY,CODEX_CONCURRENCY,GEMINI_CONCURRENCY
Use the existing Make targets:
make startThis performs:
bun install- Build (
bun run build) - Start app via PM2 using
ecosystem.config.cjs
Useful operations:
make status
make logs
make restart
make deploySet your webhook endpoint to:
https://<your-public-host>/webhook
The service expects:
- Header:
X-Gitlab-Token(must matchGITLAB_WEBHOOK_SECRET) - JSON payloads from GitLab webhook events
Project settings -> Webhooks:
- URL:
https://<your-public-host>/webhook - Secret token: value of
GITLAB_WEBHOOK_SECRET - Enable events:
- Issue events
- Merge request events
- Comments
The repo includes a webhook automation script:
bun scripts/setup-webhooks.ts https://<your-public-host>/webhookPrerequisite: glab CLI must be installed and authenticated.
Examples:
# dry-run across accessible projects
bun scripts/setup-webhooks.ts https://<your-public-host>/webhook --dry-run
# configure one project only (repo URL)
bun scripts/setup-webhooks.ts https://<your-public-host>/webhook https://gitlab.com/group/project
# configure one project only (path)
bun scripts/setup-webhooks.ts https://<your-public-host>/webhook group/project
# remove managed hooks
bun scripts/setup-webhooks.ts --remove group/projectScript behavior:
- Hook name:
gitlab-agent-webhook - Uses
GITLAB_HOST,GITLAB_TOKEN,GITLAB_WEBHOOK_SECRET - Creates/updates/removes project hooks via GitLab API
After deployment:
- Health endpoint returns OK:
curl -sS http://127.0.0.1:3000/health- PM2 app is running:
make status- Webhook delivery in GitLab shows
2xxresponses. - Mention test works:
- Comment on issue or MR with
@agent <prompt> - Confirm job acknowledgment and follow-up status comment/reaction
- Comment on issue or MR with
Unauthorizedon webhook:- Check
GITLAB_WEBHOOK_SECRETand webhook token in GitLab.
- Check
- Webhook accepted but no agent output:
- Check logs (
make logs) and verify agent CLI binaries are installed and in PATH.
- Check logs (
- Hook script failures:
- Confirm
GITLAB_TOKENhas sufficient permissions andGITLAB_HOSTis correct.
- Confirm
- PM2 starts but process exits:
- Rebuild (
make build) and inspectlogs/error.log.
- Rebuild (