一、作用

  • 使用webhooks来实现当git客户端push代码到gitlab后,jenkins会立即去gitlab拉取代码并构建。

二、步骤

1、安装插件

  • ruby_runtime(Hook插件依赖于该插件)
  • Gitlab Hook Plugin

2、Jenkins全局配置

"系统管理"->"系统设置"

第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)

说明:打两个勾,制定构建的分支

3、Jenkins项目配置

项目->"配置"

第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)

说明:勾选"poll SCM",但是时间表达式为空。

4、gitlab webhook配置

第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)

第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)

注意:

  • url是http://jenkins-server/gitlab/notify_commit
  • 勾选"Push events"
  • 不适用SSL

之后,点击下边的"test"按钮进行测试

第四十一章 微服务CICD(3)- jenkins + gitlab + webhooks + publish-over-ssh(1)

 

三、测试

修改代码后,

  • git add --all
  • git commit -m"xxx"
  • git push origin HEAD:dev

查看jenkins的编译情况。

相关文章:

  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2022-02-27
  • 2021-09-29
  • 2021-07-14
猜你喜欢
  • 2021-10-17
  • 2021-05-29
  • 2021-10-29
  • 2022-12-23
  • 2021-12-19
  • 2021-05-30
  • 2022-03-05
相关资源
相似解决方案