1

I am wanted to try out caching on my Gitlab project following documentation here - https://docs.gitlab.com/ee/ci/caching/#how-archiving-and-extracting-works. I have a project specific runner and am using docker executor, but I get error

cat: vendor/hello.txt: No such file or directory

How would I go about troubleshooting this problem? I set disable_cache = false in my runner config, but that did not help. EDIT: using private gitlab instance 12.3.

user430953
  • 191
  • 2
  • 19

2 Answers2

2

I acheived this using distributed caching which I found easy. First of all you need a S3 bucket or s3 compatible storage like minio. You can set MinIo locally where gitlab runner exsists with following commands.

docker run -it --restart always -p 9005:9000 \
        -v /.minio:/root/.minio -v /export:/export \
        --name minio \
        minio/minio:latest server /export

Check the IP address of the server:

hostname --ip-address

Your cache server will be available at MY_CACHE_IP:9005

Create a bucket that will be used by the Runner:

sudo mkdir /export/runner

runner is the name of the bucket in that case. If you choose a different bucket, then it will be different. All caches will be stored in the /export directory.

Read the Access and Secret Key of MinIO and use it to configure the Runner:

sudo cat /export/.minio.sys/config/config.json | grep Key

Next step is to configure your runner to use the cache. For that following is the sample config.toml

[[runners]]
  limit = 10
  executor = "docker+machine"
  [runners.cache]
    Type = "s3"
    Path = "path/to/prefix"
    Shared = false
    [runners.cache.s3]
      ServerAddress = "s3.example.com"
      AccessKey = "access-key"
      SecretKey = "secret-key"
      BucketName = "runner"
      Insecure = false

I hope this answer will help you

Reference:

https://docs.gitlab.com/runner/install/registry_and_cache_servers.html

https://docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching

Bilal Ali Jafri
  • 915
  • 1
  • 6
  • 17
  • Is it necessary though? In the documentation it says "Cache: Are stored where GitLab Runner is installed and uploaded to S3 if distributed cache is enabled." I dont have distributed cache enabled, because I am using just a single runner. I am not able to store them on the same server as gitlab runner is installed though, – user430953 Oct 27 '20 at 07:34
1

I managed to solve the issue thanks to this post https://gitlab.com/gitlab-org/gitlab-runner/-/issues/336#note_263931046. Basically added

variables:
GIT_CLEAN_FLAGS: none

and it worked. @Bilal's answer is definitely correct, but I was looking for slightly different solution.

user430953
  • 191
  • 2
  • 19