fedorqui
fedorqui

Reputation: 289725

GitLab continuous integration to run jobs in several branches

My .gitlab-ci.yml file contains the following job:

job1:
  script: 
    - pwd
  only: 
    - master

Using only I make this dummy job job1 run the command pwd only when it gets a push into the branch master. From the docs:

only and except are two parameters that set a refs policy to limit when jobs are built:

only defines the names of branches and tags for which the job will be built.

Now I would like to run this on multiple tags, so following the docs:

only and except allow the use of regular expressions.

I tried to say:

job1:
  script: 
    - pwd
  only: 
    - (master|my_test_branch)

But it does not work at all: neither in master nor in my_test_branch. What is wrong with the regular expression?

Upvotes: 0

Views: 139

Answers (2)

RAM237
RAM237

Reputation: 1035

Why not just to use multiple values (more readable in my opinion):

only:
    - master
    - my_test_branch

Upvotes: 1

fedorqui
fedorqui

Reputation: 289725

I did not find any documentation about it, but apparently regular expressions in .gitlab-ci.yml need to be enclosed in / /. Thus, /(master|my_test_branch)/ works.

All together:

job1:
  script: 
    - pwd
  only: 
    - /(master|my_test_branch)/

Upvotes: 0

Related Questions