stdll
stdll

Reputation: 687

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?

Upvotes: 8

Views: 7777

Answers (4)

benzguo
benzguo

Reputation: 176

I encountered the same problem - you can avoid using the github oauth plugin using:

http://user:[email protected]

Upvotes: 1

stdll
stdll

Reputation: 687

After having fiddled around with this for quite some time, I ended up using the excellent Github OAuth Plugin for Jenkins. To quote the documentation:

Since version 0.4 there is a way to authorize the use of the github-webhook callback url to receive post commit hooks from Github.

Along with the Github Plugin which triggers the build, this works most elegantly!

Upvotes: 2

Mark Theunissen
Mark Theunissen

Reputation: 2486

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

Upvotes: 3

Sasa Djolic
Sasa Djolic

Reputation: 9

Not sure if Github supports HTTPS and URLs with username and password in them, but the URL you listed does not correctly include the username and password - it should instead look like this:

https://user:[email protected]/github-webhook/

Upvotes: 0

Related Questions