利用Gitlab的webhook实现代码push到仓库,立即触发项目自动构建。

Gitlab Hook插件需要安装两个插件:Gitlab Hook和GitLab



Jenkins设置自动构建新建Item

点击确定
在构建触发器选择如下设置

复制地址,备用
http://192.168.2.3:8888/project/test03_pipeline_gitlab
在流水线出配置读取项目中的pipeline脚本

点击应用,保存
Jenkins中开启允许gitlab访问Manage Jenkins->Configure System


此处取消勾选,点击应用保存
Gitlab配置webhookwebhook功能使用root账户登录到后台,点击Admin Area -> Settings -> Network
勾选"Allow requests to the local network from web hooks and services"

点击save change
gitlab项目添加webhook首先进入当前项目主页->Settings->Integrations

填入之前在jenkins创建项目,构建触发器时获取到的URL地址


push点击Test,看能否触发执行Jenkins


此时已经成功触发

原文:https://www.cnblogs.com/ifme/p/12871495.html