Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to set up a private GitHub project to send a post-receive request to a private Jenkins instance to trigger a project build on branch push. Using latest Jenkins with the GitHub plugin.

I believe I set up everything correctly on the Jenkins side because when sending a request from a public server with curl like this:

curl http://username:password@ipaddress:port/github-webhook/

results in:

Stacktrace: net.sf.json.JSONException: null object

which is fine because the JSON payload is missing. Sending the wrong username and password in the URI results in:

Exception: Failed to login as username

I interpret this as a correct Jenkins configuration. Both of these requests also result in entries in the Jenkins log. However, when pasting the exact same URI from above into the Github repository Post-Receive URLs Service Hook and clicking on Test Hook, absolutely nothing seems to happen on my server. Nothing in the Jenkins log and the GitHub Hook Log in the Jenkins project says Polling has not run yet.

I have run out of ideas and don't know how to proceed further.

share|improve this question
    
Did you make sure that the Github server can access your Jenkins server and port? –  Lars Kotthoff Mar 18 '12 at 12:01
    
How can I verify that? There are no restrictions on who can access my server over that port from the outside. Every random online server I tried to send a request from behaved as described in the question. –  Joseph S. Mar 19 '12 at 8:34
    
I'm running into the same problem. Github doesn't seem to be sending the HTTP basic auth credentials along with the request. –  Stephen Touset Mar 28 '12 at 20:28
add comment

1 Answer

Try using Apache as a proxy in front of Jenkins. I Use NameVirtualHost...

<VirtualHost>
  --Snip---    

<Proxy *>
      AddDefaultCharSet Off
      Order deny,allow
      Allow from all
     --snip-- #You can tighten this to only allow from GITHUB ips.
</Proxy>

    RequestHeader unset Authorization
    RequestHeader set Authorization "Basic [AUTHSTRING]"
    ProxyPass / [AJP|HTTP]://[JENKINS]:[PORT]/
    ProxyPassReverse / [AJP|HTTP]://[JENKINS]:[PORT]/

</VirtualHost>

I run Jenkins in a tomcat container and use AJP, so the var [AJP|HTTP] can be either for the proxy. The [JENKINS] and [PORT] variables should be intuitive.

Now the hard part, [AUTHSTRING]!

Take the USERNAME:PASSWORD part and run it through this command:

$ echo -n 'username:password' | base64
 dXNlcm5hbWU6cGFzc3dvcmQ=

(echo -n is important to remove the newline.) Take the result and put in [AUTHSTRING]

You should be able to remove the user:password from the line at github.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.