0

Started to learn DevOps 3 days ago, so I have a lot to learn!

I have a jenkins running on docker toolbox container and I can access it via 192.168.99.100:8080. I configured a job and managed to use "Build Now" to get the files from my GitHub repository, the git is public.

I want my job to build automatically after a commit is made in my GitHub but it does not work.

I configured a webhook in my GitHub settings but after I commit, the "Webhooks" page display an error "Last delivery was not successful. Couldn't connect to server." In the URL inside the webhook I configured "http://192.168.99.100:8080/jenkins-name/" Is it wrong to use that URL? I am not sure about it.

In jenkins, I am using the GitHub plugin and I configured in "Configure System" a GitHub Server with my credentials and the "Test connection" button was verified. In the job, configured my GitHub repository in the "Source Code Management" section and in the "Build Triggers" section I checked "GitHub hook trigger for GITScm polling".

I read it have something with port forwarding.. Will appreciate any help!

1

Your configuration is wrong. Here you add http://192.168.99.100:8080/ is a local Jenkins URL. Github does not connect with the local URL. Also you give the wrong webhook-URL.

Please add your public IP of Jenkins in your webhook like http://35.24.128.75:8080/" And GitHub webhook payload url is like http://35.24.128.75:8080/github-webhook"

for Full webhook configuration please watch this video: https://www.youtube.com/watch?v=wsnq9uGAWkM&t=460s

| improve this answer | |
0

You are on the correct track with port forwarding - you will need to tell your router to forward traffic from your public IP address to your Jenkins server on a specific port.

The 192.168.x.x address is one of the Private address ranges - nobody from the external web can see any of your servers on these addresses. See https://en.wikipedia.org/wiki/Private_network for more information on private addresses if you are interested.

You probably have a modem/router to connect to your ISP. It does the work of converting all the traffic from the 192.168.x.x addresses into something that can be used in the internet. When a response comes back from the internet to your computer, the router recognizes that it is a response and sends it to the computer that initiated the request.

But if a request comes from the outside world that is not a response, the router does not know where to send it - it just drops it. This is where port forwarding comes in. You can tell your router that if it sees a request coming in on port 8080 then it should send the request to the server at address 192.168.x.x and port xxxx.

Note that the inbound port and the server port do not have to be the same. This can provide a level of security through obscurity - since most developers tend to have servers running on port 8080, some hacker scripts will try that port as a matter of course. You might want to have some random port number on your router going to port 8080 internally. (This is still not good security, but it is better than nothing.)

Edit: I left out one important thing: you need to tell GitHub to hit your public IP address in order for the port forwarding to work. You can find out just the IP by going to https://www.google.com/search?q=whats+my+ip and Google will tell you what your public IP is.

If you are connected to your ISP 24x7 then your public IP probably doesn't change that often (if ever), and this will probably work for you.

If your IP changes regularly (or you just want to go to the next level) you can look into a public dynamic dns (which requires a local client) to give you a DNS name that always points to your IP address (e.g. noip.com - I haven't used them in over a decade so I don't know if they are good or not, but at least it will give you a starting point at looking at this).

| improve this answer | |
  • Thank you very much! I managed to use a program named "ngrok" that can do port forwarding to my local jenkins server and it fixed it! – Tomerhek Feb 9 '19 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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