Tadeusz
Tadeusz

Reputation: 6903

How to clean working directory after pipeline in Gitlab CI/CD?

I use gitlab-ci/cd pipeline for my project. All is fine, but after pipeline ended all files are continuing to exists in working directory of gitlab-runner until next time pipeline will be started. Now I use "rm -rf ./*" to clean directory inside script, but I must care about files for artifacts. Is there any keyword or settings to clean working directory?

Upvotes: 1

Views: 14337

Answers (1)

Daniel Campos Olivares
Daniel Campos Olivares

Reputation: 2594

The artifacts are stored by default on /var/opt/gitlab/gitlab-rails/shared/artifacts when the Job finishes.

If you just want to take care of not deleting them before they're actually attached; you can just create a clean-up stage which sole job is to delete everything within the directory.

stages:
 - build
 - clean

build_job_1:
 stage: build
 ...

build_job_2:
 stage: build
 ...

cleanup:
 stage: clean
 script:
  - rm -rf ./*

Upvotes: 1

Related Questions