Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a ref strategy in a gitlab ci pipeline file?

I am using Gitlab and added a .gitlab-ci.yml file to trigger my pipeline. What I don't understand is the purpose of refs when used in combination with the only keyword. Here is an example I use:

only:
     - /^newlib.*$/

But in another example I found this:

only:
    refs:
      - master

The documentation only states:

The refs strategy can take the same values as the simplified only/except configuration.

Can anyone share some light on this? What is the difference between the two?

like image 622
Daniel Stephens Avatar asked Oct 24 '25 02:10

Daniel Stephens


1 Answers

There is no difference between your two examples. As you quoted the docs yourself:

The refs strategy can take the same values as the simplified only/except configuration.

That said, you only need to use refs if you also want to use the other options: changes, kubernetes and variables.

The docs has some examples using multiple options such as:

test:
  script: npm run test
  only:
    refs:
      - master
      - schedules
    variables:
      - $CI_COMMIT_MESSAGE =~ /run-end-to-end-tests/
    kubernetes: active

If you remove the refs you will get an invalid yml file

like image 116
leoschet Avatar answered Oct 26 '25 20:10

leoschet