Preface
Jenkins is a popular open source tool to perform continuous integration and build automation. Let’s take a look at how we can integrate GitHub with Jenkins for source code management and trigger build on push using web-hooks.
Prerequisites
1. Jenkins: Download and install Jenkins as described here.
2. Git: Install Git. To check whether you have git installed, open a terminal window and type below command.
3. Plugins: Add Git and GitHub Plugins.
Go to Manage-Jenkins-> Manage Plugin and search Github plugin and install without restart:
4. Go to Manage Jenkins -> Global Tool Configuration -> Git
Add git executable path to Global Tool Configuration.
How-To
Let us start with creating a Freestyle Project :
Step 1: Go to New Item -> create a freestyle project.
Step 2: Go to Configure, add a project description, and Github project URL.
Change above git clone path "https://github.com/johnklee/fpu/" to your Github clone path.
Step 3: In Build Triggers select GitHub hook trigger for GITScm polling.
When Jenkins will receive PUSH GitHub hook, it will trigger Git SCM polling logic which will start a new Jenkins build, with the updated code.
Step 4: Go to your Github repo -> settings -> webhooks
Add public URL of your tunnel as Payload URL, it will tell Github where to send the webhooks as below:
Step 5: Finally add your build steps in the Build tab and save.
That’s all! Now whenever any change is pushed, a new Jenkins build will be triggered.
沒有留言:
張貼留言