Cache

Cache in Buddy

Working speed is essential to any CI/CD tool. Buddy improves pipeline performance by caching resources that would otherwise have to be generated or downloaded on every run:

  1. Repository files, dependencies and artifacts (cached within the Pipeline Filesystem)
  2. Docker images in which build actions are run (no need to build the environment from scratch every time)
  3. Docker images used in the Run Docker Container action
  4. Docker layers built with the Docker Build action

You can also enable cache for services and databases attached to build actions or an extra cache per individual build action.

Pipeline filesystem cache

Each pipeline has its own filesystem. On the first pipeline run, the repository is cloned to the filesystem. Subsequent executions only fetch changes from the repository (git fetch).

The pipeline filesystem is available for every action executed in the pipeline:

  1. Build actions are run in a Docker container to which the filesystem is mounted. By default, all build commands are executed in the context of the filesystem.
  2. Deployment actions are also run in the context of the filesystem, enabling you to deploy artifacts built in previous actions.

The files in the filesystem are persistent: dependencies fetched on the first execution stay in the cache and don't need to be downloaded on every run.

Cache in build actions

Repository, dependencies, and artifacts

Builds, tests and other commands defined in the build action are executed in the context of the filesystem containing the repository. This is the primary cache of the pipeline.

If you fetch dependencies to a different directory than the default build context, you can cache them by entering their paths in the Caching tab: Cache tab in a Node actionCache tab in a Node action

Build environment cache

Build actions are run in Docker containers. The build environment is based on the Docker image pulled from a registry. On the first pipeline run, Buddy pulls and caches the image in the selected version. If you set the tag to 'Latest', it checks for a new version by running docker pull on every subsequent execution. The procedure only downloads Docker layers missing in the previous execution.

This way you don't have to pull the full image every time, and you're always sure that you're using the most recent version. The same rule applies to other actions that pull Docker images from the registry.

This type of cache works between all pipelines of all projects in the workspace.

Environment customization

Docker images can be customized with commands in the Packages & Tools tab of the build action. The commands are run on the first pipeline execution to create a new image. The image is used until a new one is pulled from the registry or until modified with new commands.

This type of cache works between all pipelines of all projects in the workspace.

Databases and services

All build actions support microservices (MySQL, MongoDB, Redis, etc.). The services act like individual containers with separate caching systems.

Docker

All layers created in Docker-building actions are cached. During subsequent builds, Buddy adds only the layers that have not been built in the previous step. Cached images can be used by other actions in the pipeline, including builds and Docker Push/Docker Run actions.

The Docker cache is limited to one pipeline only and cannot be shared with actions in other pipelines.

Clearing cache

Sometimes you may want to clear the cache, for example, if you need to regenerate the artifacts. In such case, you can either clear the cache manually, or select an option which will do that automatically before every execution. The operation is performed per pipeline – it is not possible to clear caches of the entire workspace at once.

Checking consumed space

You can check the volume of consumed space for each project and pipeline by switching to the Plans, Usage & Billing tab in the workspace settings.

Or directly at: https://app.buddy.works/YOUR_WORKSPACE/payments

Cache usage in workspace settingsCache usage in workspace settings

Manual purge

  1. Click the 'Clear cache' option from the pipeline's dropdown menu:

Clear cache in pipeline optionsClear cache in pipeline options

  1. Check the corresponding option when running the pipeline manually.

  2. Use /[name] clear run slash command when running the pipeline from Slack.

  3. Use the --clear-cache parameter when running the pipeline with a commit command.

Automatic purge

To automatically purge the cache on every pipeline run, check 'Clear cache before pipeline execution' in the pipeline's settings.

This option is NOT recommended as all dependencies, artifacts, and Docker images need to be downloaded and/or generated from scratch on every execution, which can drastically extend runtime.