In this example, we're going to push changes to our GitHub repository and run build in Jenkins server.


How it works


  1. User pushed local changes to GitHub.

  2. GitHub tells Jenkins to run build.

  3. Jenkins copies repository from GitHub under '/var/lib/jenkins/workspace/country' directory and runs build scripts if there are any.

Prerequisite


You must have git installed on your Jenkins server so run $ sudo apt-get install git before steps below.


Setup


1. Find GitHub web hook URL in Jenkins



2. Enable web hook URL in GitHub



3. Create a new project in Jenkins



Test


Commit a dummy file and push it to GitHub repository. If you check "country" project in your Jenkins GUI, you'll see a blue #1 icon in "Build History" which means the tests passed.