Skip to content

Proxy for converting Webhooks requests from Gitlab into something more easily readable by CI servers such as Jenkins

License

Notifications You must be signed in to change notification settings

sandrocarval/githookproxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Hook Proxy

Motivation

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.

To Run proxy

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

To use proxy

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 or note
  • STATE: only sent in merge_request, issue and note hooks
  • SOURCE_BRANCH: only sent in merge requests
  • TARGET_BRANCH: only sent in merge requests

About

Proxy for converting Webhooks requests from Gitlab into something more easily readable by CI servers such as Jenkins

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 56.6%
  • Shell 43.4%