I know that I can't have multiple gitlab-ci.yml files in one repo, but it still seems fairly limited. Say for example I have one set of tests I want to run whenever a change is pushed or on PRs, and another set I want to run every 24 hours. Is there a way to do that, or do I only get one set of tests I have to use whenever I want to run CI?
job1: script: - do something on schedule only rules: - if: '"$CI_PIPELINE_SOURCE" == "schedule"' when: always job2: script: - runs on Merge request pipeline rules: - if: $CI_MERGE_REQUEST_ID when: always when: never job2: script: - runs on changes to anything in src directory or Dockerfile rules: - changes: - src/* - Dockerfile
# Include ci files include: - local: '/templates/.scheduled-job-template.yml' # CI template with hidden job (.scheduled_job) that runs on schedule - local: '/templates/.lint-and-validate.yml' # contains jobs for linting and validating project job1: extends: - .scheduled_job rules: - if: '"$CI_PIPELINE_SOURCE" == "schedule"' when: always job2: script: - runs on Merge request pipeline rules: - if: $CI_MERGE_REQUEST_ID when: always when: never
In doing this you can compose the jobs/pipelines you want in its own yml file and then define the jobs using those templates in the gitlab-ci.yml, which will help keep things maintainable and clear if you are running numerous different pipeline/pipeline configurations from the same project.
I guess you can do it via
rules keyword. It has multiple condition with environment variables or branch name or schedules. If you add detail about you want to do, i try to