Skip to content
Skills Library
DevOps & cloud · Building & coding

gitlab-ci-artifacts-caching

/gitlab-ci-artifacts-caching

Use when configuring artifacts for inter-job data passing or caching for faster builds. Covers cache strategies and artifact management.

Repository
han ↗
Licence
Apache-2.0
Last repository change
08.09.2026

Assessment and security

95/ 100Class: good
Format20 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.09.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when configuring artifacts for inter-job data passing or caching for faster builds. Covers cache strategies and artifact management.

Original author description

Use when configuring artifacts for inter-job data passing or caching for faster builds. Covers cache strategies and artifact management.

How it works

  1. Artifacts
  2. Caching
  3. Distributed Cache (S3)
  4. Artifacts vs Cache
  5. Best Practices
Original SKILL.md headings · 172 lines, 355 words
SKILL.md preview
---
name: gitlab-ci-artifacts-caching
user-invocable: false
description: Use when configuring artifacts for inter-job data passing or caching for faster builds. Covers cache strategies and artifact management.
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash
  - Grep
  - Glob
---

# GitLab CI - Artifacts & Caching

Configure artifacts and caching for efficient pipeline execution.

## Artifacts

### Basic Artifact Configuration

```yaml
build:
  script:
    - npm run build
  artifacts:
    paths:
      - dist/
    expire_in: 1 week
```

### Artifact Reports

```yaml
test:
  script:
    - npm test -- --coverage
  artifacts:
    reports:
      junit: junit.xml
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura-coverage.xml
```

### Conditional Artifacts

```yaml
build:
  artifacts:
    paths:
      - dist/
    when: on_success  # on_success, on_failure, always
    exclude:
      - dist/**/*.map
```

### Artifact Dependencies

```yaml
build:
  artifacts:
    paths:
      - dist/

test:
  dependencies:
    - build  # Downloads build artifacts
  script:
    - npm test

deploy:
  dependencies: []  # Skip all artifact downloads
  script:
    - ./deploy.sh
```

## Caching

### Basic Cache Configuration

```yaml
default:
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/
      - .npm/
```

### Cache Key Strategies

```yaml
# Per-branch cache
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/

# Lock file based cache
cache:
  key:
    files:
      - package-lock.json
  paths:
    - node_modules/

# Combined key
cache:
  key:
    prefix: ${CI_JOB_NAME}
    files:
      - package-lock.json
  paths:
    - node_modules/
```

### Cache Policy

```yaml
install:
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/
    policy: push  # Only upload cache
  script:
    - npm ci

test:
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/
    policy: pull  # Only download cache
  script:
    - npm test
```

### Fallback Keys

```yaml
cache:
  key: ${CI_COMMIT_REF_SLUG}
  fallback_keys:
    - ${CI_DEFAULT_BRANCH}
    - main
  paths:
    - node_modules/
```

## Distributed Cache (S3)

Configure in GitLab Runner:

```toml
[runners.cache]
  Type = "s3"
  Shared = true
  [runners.cache.s3]
    ServerAddress = "s3.amazonaws.com"
    BucketName = "gitlab-runner-cache"
    BucketLocation = "us-east-1"
```

## Artifacts vs Cache

| Feature | Artifacts | Cache |
|---------|-----------|-------|
| Purpose | Pass data between jobs | Speed up job execution |
| Storage | GitLab server | Runner local or S3 |
| Reliability | Guaranteed | Best effort |
| Expiration | Configurable | Configurable |
| Cross-pipeline | Yes (with dependencies) | Yes (with keys) |

## Best Practices

1. Use cache for dependencies (node_modules, vendor)
2. Use artifacts for build outputs
3. Set appropriate expiration times
4. Use lock file-based cache keys
5. Exclude source maps and unnecessary files
6. Use `policy: pull` for jobs that only read cache

Versions

The database has no other skills named gitlab-ci-artifacts-caching.

Database snapshot: 13.11.2026 · package version e2bf05500f28 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100gitlab-ci-patterns
    Provides GitLab CI/CD pipeline patterns including stages, jobs, artifacts, caching, and environment deployments. Use when working with .gitlab-ci.yml or when the user mentions GitLab CI or GitLab pipelines.
  • 100gitlab-ci
    Expert GitLab CI/CD assistance covering .gitlab-ci.yml, stages, artifacts, caching, GitLab Runners, and Auto DevOps. Use when configuring continuous integration and deployment pipelines on GitLab.
  • 100gitlab-ci-patterns
    Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up...
  • 90gitlab-ci
    GitLab CI/CD流水线开发专家助手。当用户需要编写.gitlab-ci.yml、配置GitLab Runner与标签策略、管理缓存与artifacts、迁移only/except到rules、设计Docker构建或多环境部署流水线时调用。
  • 90gitlab-ci-handbook
    GitLab CI/CD knowledge base (GitLab 18+). Use whenever the user asks about, needs an explanation of, writes, reviews, optimizes, or debugs GitLab pipelines or .gitlab-ci.yml files: stages, jobs, rules and workflows, includes and templates, caching and artifacts, child and…
  • 100gitlab-ci-patterns
    Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up automated testing and deployment.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.