Rediģēt

Kopīgot, izmantojot


Cache@2 - Cache v2 task

Improve build performance by using this task to cache files, like dependencies, between pipeline runs. See Cache task: how it works and Reduce build time using caching for specific examples and more details.

Syntax

# Cache v2
# Cache files between runs.
- task: Cache@2
  inputs:
    key: # string. Required. Key. 
    path: # string. Required. Path. 
    #cacheHitVar: # string. Cache hit variable. 
    #restoreKeys: # string. Additional restore key prefixes.

Inputs

key - Key
string. Required.

The key (unique identifier) for the cache. This should be a string that can be segmented using |. File paths can be absolute or relative to $(System.DefaultWorkingDirectory).

While there is no defined maximum number of segments for a key, if you are getting cache misses, try using a shorter key with fewer segments, for example by creating a new key that is a hash of your segments.


path - Path
string. Required.

The path of the folder to cache. Can be fully qualified or relative to $(System.DefaultWorkingDirectory). Wildcards are not supported. Variables are supported.


cacheHitVar - Cache hit variable
string.

The variable to set based on cache restoration. It will be true when the cache is restored (i.e. a cache hit), inexact on a restore key cache hit (based on restoreKeys) or false if there is a cache miss.


restoreKeys - Additional restore key prefixes
string.

The additional restore key prefixes that the task uses if the primary key misses. This can be a newline-delimited list of key prefixes.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Improve build performance by caching files, like dependencies, between pipeline runs.

Requirements

Requirement Description
Pipeline types YAML, Classic build
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.160.0 or greater
Task category Utility

See also