简体   繁体   English

Gitlab Webhooks(同一个 repo 上有 2 个 Webhooks)

[英]Gitlab Webhooks (2 Webhooks on the same repo)

So heres the thing,所以事情是这样的,

We have two webhooks setup on the same repository in Gitlab,我们在 Gitlab 的同一个存储库上设置了两个 webhook,

Webhooks number 1 is set to url: http://jenkins.local/project/job1 (build job from master branch ) Webhooks number 2 is set to url: http://jenkins.local/project/job2 (builds job from branch "1" ) Webhooks number 1 is set to url: http://jenkins.local/project/job1 (build job from master branch ) Webhooks number 2 is set to url: http://jenkins.local/project/job2 (builds job from branch "1")

The issue we're trying to overcome is, whenever there is a mergre request being opened Both of those web hooks are being triggered.我们试图克服的问题是,每当有一个合并请求被打开时,这两个 web 钩子都会被触发。

Is there a way to "configure" the webhooks to fire only when a merge reuqest is being made into the master / 1 branch,有没有办法“配置” webhook 仅在合并请求进入 master / 1 分支时触发,

i haven't found such settings in settings -> integrations我在设置->集成中没有找到这样的设置

Webhook settings info Webhook 设置信息

Currently, the option to restrict webhooks per branch is only available for Push events;目前,限制每个分支的 webhook 选项仅适用于 Push 事件; for Merge requests events;用于合并请求事件; there isn't a way to restrict/filter.没有办法限制/过滤。

You have to filter it in your Jenkins job (which job to get fired; if that's also you looking for) as an example of GitLab plugin like this -你必须在你的 Jenkins 工作中过滤它(哪个工作会被解雇;如果这也是你要找的)作为 GitLab 插件的例子,就像这样 -

Job1:-工作1:-

triggers {
        gitlabPush {
            buildOnMergeRequestEvents(true)
            targetBranchRegex('master')
        }
    }

Job2:-工作2:-

triggers {
        gitlabPush {
            buildOnMergeRequestEvents(true)
            targetBranchRegex('branch1')
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM