Bitbucket Cache X Not Defined
A step's caches: list names a cache that is neither a built-in (like node, docker) nor declared under definitions: caches:. With no definition to bind to, the configuration is rejected.
What this error means
The pipeline fails configuration noting the named cache is not defined. Built-in cache names resolve automatically; any custom name must be declared first.
bitbucket-pipelines
Configuration error: the cache "gradle" referenced in step "Build"
is not defined under definitions > caches.Common causes
Custom cache referenced but never declared
A step caches: [ gradle ] needs a definitions: caches: gradle: <path> entry. Without it the name has no definition.
Typo or wrong built-in name
A misspelled name (nodes for node) or a custom name that does not match the definition key leaves the cache undefined.
How to fix it
Declare the custom cache under definitions
Add a definitions: caches: entry, then reference it by the same name.
bitbucket-pipelines.yml
definitions:
caches:
gradle: ~/.gradle/caches
pipelines:
default:
- step:
caches: [ gradle ]
script: [ ./gradlew build ]Use exact built-in or defined names
- For built-in caches, use the exact name (
node,pip,docker). - For custom caches, match the step name to the
definitions: caches:key. - Re-validate before pushing.
How to prevent it
- Declare every custom cache under
definitions: caches:before use. - Use exact built-in cache names.
- Keep cache names consistent between definition and step.
Related guides
Bitbucket Artifact Path Did Not Match Any FilesFix Bitbucket "artifact path did not match any files" - an artifacts paths glob that points at the wrong dire…
Bitbucket Pipeline Variable Not SetFix Bitbucket scripts that fail because a pipeline variable is not set - a repository/workspace/deployment va…
Bitbucket "Invalid YAML: mapping values are not allowed here"Fix Bitbucket "mapping values are not allowed here" - an unquoted value containing a colon, or a misindented…