To help integrate Gitlab post receive hook and do further CI with something like Jenkins.
Gitlab sends a webhook as an 'application/json' post, with the JSON as part of the post body. This makes it harder for Jenkins to read, as it usually expects parameters. This is slightly different from Github, which posts it as a 'payload' parameter.
Git hook proxy takes the Gitlab web hook and translates it into something more easily workable by Jenkins.
go build proxy.go
This will generate a 'proxy' executable.
To run the proxy:
./proxy -listen <listen address>
For Example:
./proxy -listen 127.0.0.1:9999
Add this to your Gitlab webook:
http://[proxy_listen_url]?url=[target_url]
Make sure to specify 'url' parameter to tell the proxy where to forward requests to.
The proxy will take the webhook request, and translate it to a request to the target_url in the format of:
- payload: JSON body
- START: Start commit hash
- END: End commit hash
- REFNAME: Ref name
- REPOSITORY_NAME: the repository name only (example:
myrepo
when repository URL is[email protected]:myname/myrepo.git
) - OBJECT_KIND:
tag_push
,push
,merge_request
,issue
ornote
- STATE: only sent in
merge_request
,issue
andnote
hooks - SOURCE_BRANCH: only sent in merge requests
- TARGET_BRANCH: only sent in merge requests