Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up webhooks with an independent git server?

Tags:

git

jenkins

I am using Jenkins for automated integrations and deployments. I would like the build to take place after every commit to the master branch.

So I post-commit webhook, or a post receive trigger highlighted here and here and here.

So:

curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>

I am using an independent git server (So not github or bitbucket) and I would like to create this webhook / trigger.

Any ideas on how to do this?

like image 446
tread Avatar asked Sep 29 '22 06:09

tread


1 Answers

A webhook means that you are pushing to your Git repo hosting server, which triggers a JSON payload received by any server which should react to a new push (like your Jenkins server).

But that is not exactly what is needed if one use the curl Jenkins API command highlighted in "polling must die"

You can put a post-receive hook in the bare repo to which you are pushing to (on the server side) which will call the curl command.

And the Jenkins Jobs needs to be configured with polling:

This will scan all the jobs that’s configured to check out the specified URL, and if they are also configured with polling, it’ll immediately trigger the polling (and if that finds a change worth a build, a build will be triggered in turn.)

You can see more in my previous answer "How to configure Git post commit hook".

like image 149
VonC Avatar answered Oct 02 '22 13:10

VonC