2020年4月10日 星期五

[ 常見問題 ] Triggering a Jenkins build on push using GitHub webhooks

Source From Here
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.
# git --version


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.

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...