5

My gitlab CI is as follows:

stages:
  - test

cache:
  key: ${CI_COMMIT_SHA}
  paths:
    - mymark

test:
  stage: test
  script:
    - ls -l
    - echo "hi" > mymark
    - ls -l
  tags:
    - myrunner
  only:
    - dev

The file mymark is created by the build scripts:

$ ls -l
total 76
-rw-r--r--  1 root root    3 Mar 15 10:48 mymark

But GitLab does not see it:

Creating cache 122f151d6b0a9d37cfa2172941d642e5c48287fc...
WARNING: mymark: no matching files                 
Created cache
Job succeeded

This seems to happen randomly: sometimes the file is found, sometimes not:

Creating cache 63d295dad175370aa61d13c4d2f3149e050df5e0...
mymark: found 1 matching files               
Created cache
Job succeeded
2
  • Have you found a solution to this problem yet? Commented May 14, 2018 at 6:43
  • Related: stackoverflow.com/q/53953122/320399 Commented Sep 9, 2021 at 20:33

2 Answers 2

3

This is because cache can only be used for files inside your project, so even

cache:
  paths:
    - /my_root_path

will let GitLab CI look for /home/user/yourproject/my_root_path.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't see anywhere in the code of the original question where OP is leaving the project. Am I missing something?
0

This can happen when you cd out of the original directory in any before_script or script directive.

Make sure you cd back to the original directory you were in so the cache code can see the paths its looking for.

1 Comment

I don't see anywhere in the code of the original question where OP is doing a cd out of the original directory. Am I missing something?

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.