Magnus Lundberg
Magnus Lundberg

Reputation: 803

GitLab only builds for specific tag names

Is there a way to instruct the pipeline to only do a step for certain tags that matches a regular expression?

I would like it to do a deploy when I push a tag on the format 1.2.3 (for example). Is there a way to do this?

Upvotes: 44

Views: 42018

Answers (3)

ricekot
ricekot

Reputation: 370

You can also make use of rules:

job:
  script: echo "Hello, World!"
  rules:
    - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'

Upvotes: 23

Rufinus
Rufinus

Reputation: 30753

Yes, you can do this with the only option:

job:
  # Use regexp
  only:
    - /^issue-.*$/


job:
  # Use special keywords
  only:
    - tags
    - triggers
    - schedules

See only/except (basic).

Upvotes: 31

Jonas Geiregat
Jonas Geiregat

Reputation: 5442

This should only be run for refs that are not branches named matching the given regex.

   job:
      only:
        - /^(\d+\.)?(\d+\.)?(\*|\d+)$/
      except:
        - branches

Upvotes: 57

Related Questions