Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop gitlab runner to not remove a directory

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?

like image 213
PHA Avatar asked Mar 22 '17 09:03

PHA


1 Answers

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.

Note

  • If you need to pass artifacts between different jobs, you need to use dependencies.
  • Gitlab has a good documentation about that if you really have this need http://docs.gitlab.com/ce/ci/yaml/README.html#dependencies
like image 92
Ala Eddine JEBALI Avatar answered Nov 03 '22 11:11

Ala Eddine JEBALI