0

I am creating a pipeline for a gitlab repo that will have 4 jobs, each job will run depending on which sub-directory in the root directory was changed. The pipeline will run on every merge request created and committed to.

I have followed the gitlab documentation and any other source I could find, but I just cannot get it to work. I would be very grateful if someone could point me in the right direction.

I the following yml configuration it will run all 5 jobs on every merge request regardless of what was changed or even if anything was changed.

image: node

stages:
  - test

job1:
  stage: test
  script:
    - cd dir1
    - yarn test:ci
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - dir1/**/*.js

job2:
  stage: test
  script:
    - cd dir2
    - yarn test:ci
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - dir2/**/*.js

job3:
  stage: test
  script:
    - cd dir3
    - yarn test:ci
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - dir3/**/*.js

job4:
  stage: test
  script:
    - cd dir4
    - yarn test:ci
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - dir4/**/*.js

job5:
  stage: test
  script:
    - cd dir5
    - yarn test:ci
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - dir5/**/*.js

0 Answers0