Volume Cache

by drillster

The volume cache plugin can be used to preserve files and directories between builds. The below pipeline configuration demonstrates simple usage.

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  build:
    image: node
    commands:
      - npm install

  rebuild-cache:
    image: drillster/drone-volume-cache
    rebuild: true
    mount:
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

The mount attribute defines a list of files or directories that should be cached and restored.

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
+   mount:
+     - node_modules
    volumes:
      - /tmp/cache:/cache

The rebuild flag instructs the plugin to copy files from the build environment to the host machine. This should be declared at the end of your pipeline.

pipeline:
  rebuild-cache:
    image: drillster/drone-volume-cache
+   rebuild: true
    mount:
      - node_modules
    volumes:
      - /tmp/cache:/cache

The restore flag instructs the plugin to copy files from the host machine to your build environment. This should be declared at the beginning of your pipeline, before your build steps.

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
+   restore: true
    mount:
      - node_modules
    volumes:
      - /tmp/cache:/cache

The volume attribute defines the path on the host machine where the cache is stored. The host machine volume must be mounted into container path /cache.

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - node_modules
+   volumes:
+     - /tmp/cache:/cache

Parameter Reference

restore
instruct plugin to restore cache, can be true or false
rebuild
instruct plugin to rebuild cache, can be true or false
mount
list of folders or files to cache

Additional Functionality

The volume cache plugin reacts to special directives in a commit message to provide additional functionality. Include one of the following directives somewhere in your commit message to trigger their respective actions:

[CLEAR CACHE]
instruct the plugin to clear the entire cache. This only influences the restoring step, the plugin will still rebuild cache if instructed to do so.
[NO CACHE]
instruct the plugin not to restore or rebuild cache for this build.

Is there a mistake on this page? Please let us know or edit this page.