Jenkins auto build when git commit

Introduction

In this tutorial, How to use Jenkins auto-build when git commit. You use a webhook to capture when a new git commit was made and Jenkins will start to build jobs.

Step-by-Step Guide to Jenkins Auto Build on Commit

Configuration Setup

  • Jenkins Server
  • Install GitHub and Git plugins

For instructions on setting up Jenkins on AWS EC2, please refer to the installation guide.

How to Install the Git and Github plugins.

Under ‘Manage Jenkins’ -> ‘Manage Plugins’, select and install both Github and Git plugins.

Restart to finish the installation.

Configure a Jenkins job to use your repository.

Create a Jenkins job ‘Freestyle project

Jenkins auto-build when git commit

First, You add a repository in the “Github project” text field under the general settings.

Jenkins auto-build when git commit

you’ll need to enable Git under ‘Source Code Management

Jenkins auto-build when git commit

Under ‘Build Triggers‘, tick ‘GitHub hook trigger for GITScm polling‘.

Add the hooks to Github.

Click “settings” for your repository. For Example, My repository https://github.com/huupv/jenkins/settings/hooks . Click ‘Add webhook‘ as the picture.

Jenkins auto-build when git commit

Setting webhooks for Jenkins.

Jenkins auto-build when git commit
Jenkins auto-build when git commit

Conclusion

When you commit changes to a repository on GitHub, Jenkins will automatically trigger a build job. Test it out and see how it works! I hope you find this information useful. Thank you for visiting the DevopsRoles website!

, ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.