Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need help setting up a github webhook with a localhost jenkins

I have: - a public github repository - a localhost:8080 jenkins - a java maven project connected to the github repository - a jenkins job connected to the github repo I am able to trigger manual builds anytime, but I want to have a build triggered at each commit pushed to the github repository.

like image 986
jackoo Avatar asked Nov 17 '15 20:11

jackoo


People also ask

How do I create a Jenkins GitHub webhook?

Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.

How do I use GitHub Webhoks on localhost?

Under "Payload URL", enter the localhost. run URL (plus any required path), choose application/json or Form encoding for "Content type", enter a secret for securing your webhook, and choose the events you want. And that's it! Using localhost.

How do I get localhost Webhooks?

In order to receive webhook calls on your localhost you will need to create a tunnel in order to expose your application to the outside world and similarly receive request from outside as well. In this tutorial we will use ngrok to setup tunnel and will use http://sample-app.test as example localhost application.


2 Answers

If you want to start a build when a change is pushed to GitHub you need to configure the Github's Webhook: Head over to the GitHub repo and click Settings. Click the Webhooks & Services tab, and then the Add service drop-down. Select the Jenkins (GitHub plugin) service. And finally, your Jenkins hook url:

http://JENKINS.SERVER.IP.ADDRESS:8080/github-webhook/

Therefore, you need a public IP address or DNS for allowing GitHub to trigger your Jenkins build.

like image 195
sergi Avatar answered Nov 15 '22 17:11

sergi


There is an option in jenkins under "Build Triggers" where you can check off the "Build when a change is pushed to GitHub". This will poll the github repository for any change. If any change is found, a build will be triggered automatically.

Build Triggers

You can configure the schedule to poll SCM as well.

like image 34
Atri Avatar answered Nov 15 '22 17:11

Atri