Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab-CI: run job only when all conditions are met

Tags:

gitlab-ci

In GitLab-CI document, I read the following contents:

In this example, job will run only for refs that are tagged, or if a build is explicitly requested via an API trigger or a Pipeline Schedule:

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

I noticed the document uses or instead of and, which means the job is run when either one condition is met. But what if I want to configure a job to only run when all conditions are met, for instance, in a Pipeline Schedule and on master branch?

like image 729
Sah Avatar asked Jan 20 '18 22:01

Sah


1 Answers

If your specific question is how do I only run a pipeline on master when it was scheduled this should work:

job:
  only:
    - master
  except:
    - triggers
    - pushes
    - external
    - api
    - web

In this example you exclude all except for the schedules 'trigger' and only run for the master branch.

like image 105
Stefan van Gastel Avatar answered Nov 23 '22 17:11

Stefan van Gastel