MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to trigger a jenkins job when code is pushed to github using “GitHub hook trigger for GITScm polling”

Diagram: developer commits and pushes to GitHub repo, which triggers a Jenkins job
 
The GitHub plugin for Jenkins is the most basic plugin for integrating Jenkins with GitHub projects. If you are a GitHub user, this plugin enables you to:
 
  • Schedule your build
  • Pull your code and data files from your GitHub repository to your Jenkins machine
  • Automatically trigger each build on the Jenkins server, after each Commit on your Git repository
This saves you time and lets you incorporate your project into the Continuous Integration (CI) process.
 

Step 1 – Install the Github Jenkins plugin

Go to “Manage Jenkins” –> “Manage Plugins” –> “Available” Tab –> Search for “GitHub plugin” and install it.

Jenkins Plugin Manager Installed tab with GitHub plugin 1.29.5 circled

Step 2 – Configure the “GitHub plugin” with github accounts and taken

Go to “Manage Jenkins” –> “Configure System” –> Locate “Github” section and “Add Github Server” and do following modification.

  • API URL – If you server is github.com, your “API URL” would be “https://api.github.com”. Otherwise if you use GitHub Enterprise, specify its API endpoint here (e.g., https://ghe.acme.com/api/v3/).
  • Credentials – You can create your own personal access token in your account GitHub settings. Token should be registered with scopes. Refer https://github.com/settings/tokens/new . Add credentials (your Github token) and Apply.
  • “Test Connection”.
Jenkins Configure System GitHub Server settings with API URL https://api.github.com and credentials
GitHub new personal access token page named jenkins with repo, packages and admin scopes selected

Step 3 – Configure Jenkins Job on which you want push trigger should be effective.

  • Check the GitHub project checkbox and set the Project URL to point to your GitHub Repository
  • Under Source Code Management, check Git and set the Repository URL to point to your GitHub Repository
  • Under Build Triggers, check the “GitHub hook trigger for GITScm polling” checkbox
Jenkins job General tab with GitHub project checked and helloworld-java-maven project URL
Jenkins Source Code Management set to Git with helloworld-java-maven repository URL and master branch
Jenkins Build Triggers with GitHub hook trigger for GITScm polling checked

Step 4 – Configure “webhook” on github for the specific repository.

Go to repostory settings and then “Webhooks” and Click on “Add Webhook” and then fill a “Payload URL” and leave secret empty. “Payload URL” must be your jenkins server url postfix with “/github-webhook/”. Such as http://35.154.114.196:8080/github-webhook/

GitHub webhook settings with payload URL ending /github-webhook/ and Just the push event selected

Step 5 – Commit and push in Git repo using workstation and verify the job triggered new build or not?


git clone git-url
cd helloworld-java-maven/
vi readme.txt
git add --all
git commit -m"adding"
git push origin masterCode language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Jenkins Interview Questions, Answered: CI, APIs, Installation, Backups, and Essential Plugins

This revised guide turns common Jenkins interview prompts into practical answers you can explain with confidence. It covers CI fundamentals, API usage, setup on Ubuntu and RHEL-like systems, backup strategy, and key plugins.

Read More

How to build jobs in jenkins when a change is pushed to Bitbucket

ย  ย  Bitbucket plugin is designed to offer integration between Bitbucket and Jenkins. ย  It exposes a single URI endpoint that you can add as a WebHook…

Read More

How to Integration Jira with Jenkins as part of CI/CD?

Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have…

Read More

What is Jenkins and Why we need it?

What is jenkins? Web Based tool to automate manual steps for any repetitive SDLC daily tasks. Continuous integration tool Continuous delivery tool Jenkins can integrate with any…

Read More

Jenkins Interview Questions and Answers โ€“ Part 5

The easiest way to get a plugin for Jenkins is ______________ . from inside Jenkins itself (Ans) by building it from source creating a plugin request call…

Read More

DevOps Explained: Why It Matters in Modern Software Development

Introduction Modern software engineering is no longer limited to writing code and building applications. A successful software product must also be tested, deployed, monitored, secured, and continuously…

Read More
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
rajesh
rajesh
3 years ago

do to do this for pipeline job ?

robert
robert
3 years ago

hi Rajesh, what if the ip address where jenkins is located is private?
I cannot not access (from bitbucket- in my case)

Thank you!

2
0
Would love your thoughts, please comment.x
()
x