Continuous integration environment (6)-Git hook automatically triggers the build

In the previous chapter, we saw that in the built-in build trigger of Jenkins, polling SCM can realize Gitlab code update and automatic project construction, but the performance of this solution is not good.
Is there a better solution? some. It is to use Gitlab's webhook to push the code to the warehouse, which immediately triggers the automatic construction of the project.
Insert picture description here

1. Install the Gitlab Hook plugin

Two plug-ins need to be installed: Gitlab Hook and GitLab
Insert picture description here

2. Jenkins set up automatic build

Insert picture description here
You need to configure the generated webhook URL into Gitlab later

3. Gitlab configuration webhook

3.1 Enable webhook function (log in with root account)

点击Admin Area -> Settings -> Network勾选"Allow requests to the local network from web hooks and services"
Insert picture description here

3.2 Add webhook to the project

Click Project->Settings->Integrations
Insert picture description here

3.3 Configuration in Jenkins

The following settings must be completed, otherwise an error will be reported!
Manage Jenkins->Configure System
Insert picture description here
3.4 Verification
Insert picture description here
Open two windows, click Push events in Test, and then when you see that it returns to normal, refresh another window, you will find that the build starts, which means success.
Insert picture description here

It's all here. For more articles, please refer to the personal WeChat public account ALL In Linux, let's scan it!

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44729138/article/details/115098868