Skip to main content
Plugins / S3 Cache

S3 Cache

by Loric André
codeberg.org/landre/woodpecker/cache
Website
caches3

Cache file or folders to S3-compatible storage


Overview

This plugin caches a file of folder to S3-compatible storage, like AWS S3 or Cloudflare R2

Features

  • Customizable cache keys
  • Optional gzip compression (enabled by default)

Note: automatic expiry is not supported, use your S3 provider's configuration tools

Settings

Settings Name Default Description
action none The action to perform. Supported values: download, upload, clear
bucket none The bucket name
path none The file or directory to store as cache
key {{branch}}-{{arch}} The cache key, will be used as a subdirectory name. Arch will be set to the current architecture (uname -m) and the branch is the current branch ($CI_COMMIT_SOURCE_BRANCH if set, $CI_COMMIT_BRANCH for commits and $CI_REPO_DEFAULT_BRANCH for other events)
key_suffix none A custom suffix to add to the cache key
target_path $CI_REPO The path to the directory in the object storage to store the cache in
access_key_id none S3 Access Key ID
secret_access_key none S3 Secret Access Key
region auto S3 region
overwrite true Unset to avoid overwriting existing files in download mode
url none S3 API URL (leave empty for AWS S3)
compress true Unset to disable compression before sending (if you care more about CI speed than storage size)
debug false Set to enable debug logging

Examples

- name: cache
  image: quay.io/landre/woodpecker/cache
  settings:
    action: download
    bucket: woodpecker-cache
    access_key_id:
      from_secret: s3_access_key_id
    secret_access_key:
      from_secret: s3_secret_access_key
    path: node_modules
  when:
    branch: ${CI_REPO_DEFAULT_BRANCH}
    event: push
  failure: ignore # Ignore failure to avoid stopping the CI if the cache doesn't exist yet