3

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.

Joseph S.
  • 171
  • 1
  • 2
  • 4
  • 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 08: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

1 Answers1

1

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.

Electrawn
  • 111
  • 3