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.
1. Install the Gitlab Hook plugin
Two plug-ins need to be installed: Gitlab Hook and GitLab
2. Jenkins set up automatic build
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"
3.2 Add webhook to the project
Click Project->Settings->Integrations
3.3 Configuration in Jenkins
The following settings must be completed, otherwise an error will be reported!
Manage Jenkins->Configure System
3.4 Verification
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.
It's all here. For more articles, please refer to the personal WeChat public account ALL In Linux, let's scan it!