Jenkins hook configuration Gitlab

table of Contents

1, the installation Gitlab Hook Plugin plugin

2, a hook configuration information acquired in the Jenkins' Job

3, arranged at the end of the hook GitLab

4, page test hook


    After you have installed Jenkins and configured the basic infrastructure components (Jdk, git client, maven, etc., you can refer to the installation and use of Jenkins (Centos7) ), and has been normal use Jenkins publishing project services (refer Jenkins deploy traditional items and Spring Boot project later), we can click on Job creation in Jenkins, the installation process to publish pre-specified service. Then in addition we manually click Publish, Jenkins also provides a trigger trigger mechanism, that is, when the code repository (such as GitLab) sends changes and other items will be automatically released.

1, the installation Gitlab Hook Plugin  plugin

2, a hook configuration information acquired in the Jenkins' Job

    Jenkins of each task, the hook Build Triggers arranged at the acquired address Jenkins hook callback generation, and can be configured Secret token . These two later need to copy the configuration information on GitLab as follows:

3, arranged at the end of the hook GitLab

    In the end GitLab can configure a global hook, a hook can also be configured in the project (recommended configuration directly on the project, you can configure fine-grained). After entering the item select Settings ->  Integrations , entered the hook configuration page. Each project can configure multiple hooks, configured according to different trigger conditions. For example, our project will be installed before the test and development environments, configuration and condition triggers Depending on the project branches (Branch).

    Enter the page,

1、将jenkins上的钩子地址和Secret token拷贝到上面,

2、并且配置触发条件,我们一般选择

Push events 往仓库中进行push操作,并且可以配置分支(如:dev)

Merge request events  往该分支上进行merge操作时

其他是提交Comments,往tag上推,提问题等就可以不用配置了。。。

如下图:

 点击Add webhook,这样就已经配置好了钩子。

4、页面测试钩子

   添加好钩子后,在下面的列表中查看是否配置好,并且可以点击Test 中的事件进行触发钩子测试。如下图:

点击后,如果事件发生成功:

再看看Jenkins上是否已经触发了:

 

 

 

 

 

Guess you like

Origin blog.csdn.net/it_lihongmin/article/details/93925769