【发布时间】:2021-10-26 17:05:14
【问题描述】:
我正在尝试使用 Azure Pipelines 中的 Cache 任务进行 Docker 设置。根据documentation我需要设置以下参数:
- 密钥(必需)
- 路径(必填)
- RestoreKeys(可选)
- task: Cache@2
inputs:
key: 'docker | "$(Agent.OS)" | cache'
path: '$(Pipeline.Workspace)/docker'
很遗憾,缓存 任务的后期作业总是因此错误而失败。有什么建议吗?
Starting: Cache
==============================================================================
Task : Cache
Description : Cache files between runs
Version : 2.0.1
Author : Microsoft Corporation
Help : https://aka.ms/pipeline-caching-docs
==============================================================================
Resolving key:
- docker [string]
- "Windows_NT" [string]
- cache [string]
Resolved to: docker|"Windows_NT"|cache
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session xxxx
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `docker|"Windows_NT"|cache`
There is a cache miss.
tar: could not chdir to 'D:\a\1\docker'
ApplicationInsightsTelemetrySender correlated 1 events with X-TFS-Session xxxx
##[error]Process returned non-zero exit code: 1
Finishing: Cache
更新:根据建议的答案对创建方向进行更改后,缓存已被命中,但其大小为 0.0MB。我们需要自己处理副本吗?
Starting: Cache
==============================================================================
Task : Cache
Description : Cache files between runs
Version : 2.0.1
Author : Microsoft Corporation
Help : https://aka.ms/pipeline-caching-docs
==============================================================================
Resolving key:
- docker [string]
- "Windows_NT" [string]
- cache [string]
Resolved to: docker|"Windows_NT"|cache
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session xxxxxx
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `docker|"Windows_NT"|cache`
There is a cache hit: `docker|"Windows_NT"|cache`
Used scope: 3;xxxx;refs/heads/master;xxxx
Entry found at fingerprint: `docker|"Windows_NT"|cache`
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Extracting archive:
Expected size to be downloaded: 0.0 MB
**Downloaded 0.0 MB out of 0.0 MB (214%).
Downloaded 0.0 MB out of 0.0 MB (214%).**
Download statistics:
Total Content: 0.0 MB
Physical Content Downloaded: 0.0 MB
Compression Saved: 0.0 MB
Local Caching Saved: 0.0 MB
Chunks Downloaded: 3
Nodes Downloaded: 0
--
Path =
Type = tar
Code Page = UTF-8
Everything is Ok
【问题讨论】:
-
这个目录存在吗?就像它是否曾经在您的管道中创建或从回购中克隆?
$(Pipeline.Workspace)/docker。请分享更多您的管道和文件夹结构。 -
该文件夹不存在,我认为 CacheTask 会这样做。我们是否也需要将复制命令写入该文件夹,否则 CacheTask 会将 docker 图像复制到该文件夹。@TheFool
标签: docker azure-devops azure-pipelines docker-build azure-caching