All Products
Search
Document Center

Apsara Devops:Cache settings

Last Updated:Mar 19, 2025

This topic primarily focuses on the configuration and maintenance of pipeline cache settings.

Cache settings

During the execution of a Flow pipeline, each task node creates a new build environment that is destroyed after the build completes. To prevent the repeated downloading of build dependencies during pipeline execution and to enhance build efficiency, Flow offers a caching feature. Users can customize the cache directory to enable cache sharing across multiple pipeline task runs.

For instance, when executing npm install in a Node.js build task, ./node_modules is generated in the project, and the cache is stored in /root/.npm. You can preserve /root/.npm for quicker subsequent downloads.

Set cache directory

Navigate to the pipeline editing page, select Variables And Cache > Cache, and configure the Cache Directory. Currently, Flow does not support cache sharing between tasks within the same pipeline run. Flow's caching capability is designed to address the issue of downloading dependencies across multiple task runs.

  • Flow caches the following directories by default. You can enable or disable the default cache directories as needed and modify them as required.

    Management tools

    Cache directory

    Maven

    /root/.m2

    Gradle

    /root/.gradle/caches

    NPM

    /root/.npm

    yarn

    /root/.yarn

    go mod

    /go/pkg/mod

    Other cache

    /root/.cache

    高的 (37)

  • You can add custom cache directories, which must adhere to the following rules:

    • Do not specify directories such as /, /root, /root/workspace, or /root/workspace/.

    • Do not include .. in the directory path, as in /root/abc/.., which is invalid.

    • The directory must be valid, for example, /root/%\&dfaf is not a valid directory.

    If you need to cache a directory or file under the workspace /root/workspace during the build process, you can copy it to another directory under /root and designate it as the cache directory. Refer to the following example:

    image.png

    高的 (39)

    image.png

Use cache in build tasks

Once the cache directory is set, you can decide whether to prioritize using the cache when executing the pipeline with the corresponding build command parameters.

  • When building with npm, use the following command to install dependencies:

    // Prioritize using the cache during the build
    npm install --prefer-offline --no-audit
  • When building with yarn, use the following command to install dependencies:

    // Prioritize using the cache during the build
    yarn install --prefer-offline