Skip to content

[CI] How to trigger a build for specific branch on tag creation (.gitlab-ci.yml config)?

Description

I want to trigger different builds on events connected with branch "dev" for two scenarios:

  1. push commit to dev branch:

    • perform build 1

This is simple. In .gitlab-ci.yml i have:

build1:
  only:    
    - develop
  1. tag only on branch dev:

    • perform build 2

In .gitlab-ci.yml i have:

build2:
  only:
    - develop
    - tags

This triggers a build on every tag creation in repo, even on master branch. This is not what I want from CI. I want to trigger build only if tag is created on dev branch. Is it possible with gitlab CI?