jenkins是一个CI工具,其有个插件gitlab hook plugin,可以识别gitlab发送过来的提交信息,并触发对应的job。
配置功能:
- jenkins上只需要配置源代码来自git地址,不需要任何额外的配置;
- 在gitlab的某个项目的web hook配置中,配置固定的触发地址:
- 当gitlab的指定项目有push后,当push完成时,会触发指定的jenkins server上的对应job,匹配原则为:git project url地址一致,branch一致;
Build now hook
Add this web hook on your GitLab project:
http://your-jenkins-server/gitlab/build_now
Plugin will parse the GitLab payload and extract the branch for which the commit is being pushed and changes made. It will then scan all Git projects in Jenkins and start the build for those that:
- match url of the GitLab repo
- match the configured refspec pattern if any
- and match committed GitLab branch
Notes:
- for branch comparison, it will take into account both the branch definition and the strategy (this is different from the original notifyCommit)
- the project must be enabled
- you don't have to setup polling for the project