Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear cache on building Gitlab?

Gitlab can't clean my cache on building. How to fix this problem?

Executor: shell

Fetching changes...
warning: failed to remove config/__pycache__/__init__.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/local.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/__init__.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/common.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/test.cpython-36.pyc
warning: failed to remove docs/__pycache__/__init__.cpython-36.pyc
like image 576
Mitya Grebenshchikov Avatar asked Feb 21 '17 09:02

Mitya Grebenshchikov


People also ask

How long does Gitlab cache last?

all tiers. self-managed. By default, GitLab caches application settings for 60 seconds.

What is cache in Gitlab-CI Yml?

A cache is one or more files that a job downloads and saves. Subsequent jobs that use the same cache don't have to download the files again, so they execute more quickly. To learn how to define the cache in your . gitlab-ci. yml file, see the cache reference.

What is Before_script in Gitlab-CI?

These are scripts that you choose to be run before the job is executed or after the job is executed. These can also be defined at the top level of the YAML file (where jobs are defined) and they'll apply to all jobs in the . gitlab-ci. yml file.


2 Answers

Luckily I was having the exact same issue as you (I think).

A little background:

I was using gitlab ci to build using a remote runner (shell) that would build a docker image and then run some tests.

Cause:

I was mounting a local directory inside the container by passing the -v flag to docker run (there are other ways to do this with compose yml for example).

Because the docker container runs as root the generated __pycache__ directories and files are owned by root on the local filesystem; This means that docker-runner does not have permission to delete them on the next build.

The solution:

Remove the mount and copy the files instead.

like image 142
Goran Avatar answered Oct 23 '22 03:10

Goran


I workaround by not let python create *.pyc files

https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE

like image 36
joe Avatar answered Oct 23 '22 04:10

joe