简体   繁体   English

停止gitlab runner以不删除目录

[英]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: 我试图在.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. 在第一个构建中,生成了cache.zip但是对于下一个构建,删除了target_directory并且提取了cache.zip,这需要很长时间。 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? 有没有办法让gitlab runner首先删除目录?

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: .gitlab-ci.yml文件:

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 注意

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM