Demo : using github webhooks with jenkins
- ngrok or smee : This is required to provide a pulic IP
- jenkins
- A custom proxy server to forward the request to jenkins
- create a dummy github repo similar to this
- start ngrok in one of the terminal. It will show the public url which needs to go in the webhooks section.
ngrok http 9090
ngrok will forward the request on localhost 9090
- start the custom proxy server you can also use webhookproxy
./GitWebhookProxy -listen=localhost:9090 -upstreamURL=http://localhost:8080 -allowedPaths=/github-webhook
- start jenkins on docker
docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk11
-
login in jenkins and create a new job.
-
under
Source Code Management
choosegit
and add the current repo. -
under branches enter */main
-
under
build trigger
selectGitHub hook trigger for GITScm polling
-
create git hooks