0

I am trying to setup a monorepo with GitLab CI/CD. I want to define the jobs for each sub project under that project and not on the root gitlab-ci.yml file. So right now I have:

cache:
  key: $CI_COMMIT_REF_SLUG
  paths:
    - infrastructure/node_modules/
    - infrastructure/dist/
    - frontend/node_modules/
    - frontend/dist/

include:
  - local: '/infrastructure/infrastructure.gitlab-ci.yml'
    rules:
      - changes:
        - 'infrastructure/*'
  - local: '/frontend/frontend.gitlab-ci.yml'
    rules:
      - changes:
        - 'frontend/*'

Originally the cache was also moved to each folder, but I was also trying with moving just the cache to the root gitlab-ci.yml.

The problem that I'm facing right now is that if only 1 sub-pipeline runs, everything works properly, but if both running together, because I have changes in both folders, only the frontend pipelines are running properly, however the infrastructure caching is not working.

When only infra pipeline is running, it works fine, so I have the node_modules shared between the jobs.

3
  • How many runners do you have? Are you using the gitlab.com shared runners? Commented Nov 18, 2024 at 15:40
  • Yes, I'm using the default gitlab runners at the moment. I resolved the issue by using artifacts, but I would still be happy to understand what is the real issue. Commented Nov 18, 2024 at 22:50
  • I'm glad you resolved your issue! The issue with caching is not knowing that the cache is local only on that single runner unless you've configured it to use something like Minio or AWS S3. The Gitlab.com default runners do not have this set up so the cache is only on the run runner that runs the job. Also, they have thousands of runners so it's unlikely that that job will be run on the same runner in the future, so the cache is never there to use it. See my previous answer for more: stackoverflow.com/questions/69297533/… Commented Nov 20, 2024 at 21:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.