Search code examples
gitlabhookpushcontinuous-delivery

Triggering GitLab push events on multiple branches


How can I set two or more branches to trigger the hook? enter image description here

For example: I have three branches: master; develop and fix. I want the hook to work for master and develop.


Solution

  • gitlab-org/gitlab-foss issue 20338 which introduced "filter push events by branch" in GitLab 11.3 (Sept. 2018) includes:

    support for branch patterns with wildcards (*), like we do with protected branches.

    So the pattern itself is fairly limited:

    | Wildcard Protected Branch | Matching Branches                                |
    |===========================|==================================================|
    | *-stable                  | production-stable, staging-stable                |
    | production/*              | production/app-server, production/load-balancer  |
    | *gitlab*                  | gitlab, gitlab/staging, master/gitlab/production |
    

    There is no xxx|yyy or syntax.

    In your case, the pattern *e* would be enough to select only master and develop, not fix.