Background: Pipeline caching allows one to store a folder and re-use it on the next build, given that some keys, branches and whatnot matches. Useful for node_modules, nuget packages and Git LFS, but also for builds
I can't find anything in the Pipeline Caching docs for this.
I want to save the cache even if the build fails, for incremental builds or Git LFS checkouts, such as the following scenario:
The example list something like this:
- task: Cache@2
inputs:
key: 'yarn | "$(Agent.OS)" | yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
yarn
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages
But it only ever caches if the entire pipeline succeeds.
How do i store Azure DevOps pipeline cache even if a step fail (like tests)?
After a period of investigation and discussion, I am afraid there is no such task/feature to store Azure DevOps pipeline cache even if a step fail.
According to the document Pipeline caching, this task are used to help reduce build time by allowing the outputs or downloaded dependencies from one run to be reused in later runs, thereby reducing or avoiding the cost to recreate or redownload the same files again.
It does not parse the file or the build log. So, even if we cached the file generated by the failed pipeline, we cannot use that file that was not generated correctly or not generated during the next time. It seems very difficult to extract the correct information in a failed build.