Reputation: 1668
I have a directory which is generated during a build and it should not be deleted in the next builds. I tried to keep the directory using cache in .gitlab-ci.yml:
cache:
key: "$CI_BUILD_REF_NAME"
untracked: true
paths:
- target_directory/
build-runner1:
stage: build
script:
- ./build-platform.sh target_directory
In the first build a cache.zip is generated but for the next builds the target_directory is deleted and the cache.zip is extracted which takes a very long time. Here is a log of the the second build:
Running with gitlab-ci-multi-runner 1.11.
on Runner1
Using Shell executor...
Running on Runner1...
Fetching changes...
Removing target_directory/
HEAD is now at xxxxx Update .gitlab-ci.yml
From xxxx
Checking out xxx as master...
Skipping Git submodules setup
Checking cache for master...
Successfully extracted cache
Is there a way that gitlab runner not remove the directory in the first place?
Upvotes: 19
Views: 16979
Reputation: 81
For Gitlab Runner >= 11.10, you can use GIT_CLEAN_FLAGS
.gitlab-ci.yml
:
variables:
GIT_CLEAN_FLAGS: -ffdx -e target_directory/
script:
- ls -al target_directory/
According to the log you posted, it is git clean
which remove your target_directory
.
So you can tell git clean
not to remove your target_directory
by setting variable GIT_CLEAN_FLAGS
as documented by GitLab & git.
Upvotes: 7
Reputation: 7851
What you need is to use a job artifacts:
Artifacts is a list of files and directories which are attached to a job after it completes successfully.
.gitlab-ci.yml
file:
your job:
before_script:
- do something
script:
- do another thing
- do something to generate your zip file (example: myFiles.zip)
artifacts:
paths:
- myFiles.zip
After a job finishes, if you visit the job's specific page, you can see that there is a button for downloading the artifacts archive.
Upvotes: 8