Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect Github to secured Jenkins via HTTP Post-Commit Hook

I have set up Jenkins with the Github plugin on my test server. I have secured Jenkins by only allowing authenticated users (anonymous users don't have any rights) and secure connections.

Unfortunately the post-commit hook offered by Github doesn't seem to work in my case. I've tried to access the URL at https://jenkins.on.my.server/github-webhook/ manually and it gave me a "net.sf.json.JSONException: null object" error, which is fine since I didn't post any JSON along with my request.

My question:

I have secured Jenkins with authenticated users, thus I have to use a URL in the format https://user@pw:jenkins.on.my.server/github-webhook/, right? As I don't want to post the credentials all over the net, can I use a secure connection as post-commit hook for Github?

like image 776
stdll Avatar asked Aug 05 '11 13:08

stdll


1 Answers

See my blog post on this issue:

http://fourkitchens.com/blog/2011/09/20/trigger-jenkins-builds-pushing-github

We successfully use https URLS, and yes it does support the syntax you have there (it should be username:[email protected], as Sasa Djolic points out).

Make sure the the job itself it correctly configured, so when it builds, it's correctly connecting to Github and cloning the repository.

Remember that the Jenkins plugin automatically decides which jobs to build using the incoming POST data, so the jobs need to be correctly setup and building, before a remote trigger will work.

Also, ensure that the user you setup in Jenkins has the correct permissions (Overall read, Job create and Job read) as suggested here:

Jenkins and GitHub webhook: HTTP 403

like image 103
Mark Theunissen Avatar answered Oct 21 '22 09:10

Mark Theunissen