I'm setting up a Web-hook in GitHub to trigger a Jenkins build for every push event. I'm running Jenkins from a Blue Ocean Docker container.

https://i.stack.imgur.com/10HRD.jpg

I'm able to access jenkins from http://192.168.99.101:32771/ , as specified in the docker container. I have specified the git repository and checked "GitHub hook trigger for GITScm polling" checkbox.

I am able to manually kick off the build process after a commit, but when I setup the webhook in github with the payload url http://192.168.99.101:32771/github-webhook/ and commit something, I get the error "We couldn’t deliver this payload: Couldn't connect to server"

Other solutions I've looked at.

  1. Using ngrok. But I'm not running this on localhost.
  2. I tried using a Personal Access Token and created an automatic webhook from Jenkins to Github. And I got the same error.

What am I missing, or what am I doing wrong?

2

There are 2 best solutions below

1
On BEST ANSWER

Github will never reach to your Jenkins Server as your server is only accessible with-in network.

The error is very clear.

We couldn’t deliver this payload: Couldn't connect to server

http://192.168.99.101:32771 this is the same as your local host in term of access it from outside of the network.

Possible solution.

  • Run jenkins on some remote server with Internet access and give that IP in the webhook of the Github
  • Pass your public IP to Github, maybe you still issue with define port forwarding if there is any issue with access.
0
On

For anyone who's jenkins server is in a Ec2 instance of AWS and if it is in a private subnet, you can do two things:

  1. Move your private ec2 into a public subnent
  2. Create a Load balancer (ALB) within a public subnet and attach your private ec2 instance to that Load Balancer. Then use the address of ALB for you github hook.