Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I execute a job for specific branch/tag on Gitlab CI 5.4+?

Tags:

git

gitlab-ci

Latest CHANGELOG on the Gitlab CI github.com repo states that

  • Job can be branch specific or tag specific or both

Has anyone tried this feature? How would I go about making a build for a specific branch? I have not seen any obvious options for it.

Here is a screenshot of the new Job page view.

  • The Trigger option lets you choose between build for commits, tags or both.
  • AFAIK, and based on the help message, the Tags input is for determining which Runner (or group or them) should run this job, as you can associate arbitrary tags with them. These are not git tags. Am I correct? Regardless, this is rather confusing.

So, where can I configure branch/tag names for any particular job?

In my scenario, what I want to achieve is the following:

  • A push to master should run tests, perform a release and deploy to a production-like server.
  • A Merge Request from any feature branch to master, should just run tests and report coverage.
like image 712
Nicolás Fantone Avatar asked Mar 18 '23 08:03

Nicolás Fantone


1 Answers

You can do this by specifying the branches under the only: attribute in your gilab-ci.yml:

production:
  script:
    - echo 'hello world'
  only:
    - master

For another example, see here.

like image 66
ostrokach Avatar answered Mar 20 '23 07:03

ostrokach