【发布时间】:2021-08-25 05:19:57
【问题描述】:
我正在尝试将我的管道配置为在构建之间缓存 npm。 我的 pipeline.yml 是这样的
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
path: '$(npm_config_cache)'
cacheHitVar: 'CACHE_RESTORED'
restoreKeys: 'npm | "$(Agent.OS)"'
displayName: 'Cache npm'
- task: Npm@1
condition: ne(variables.CACHE_RESTORED, 'true')
inputs:
command: 'install'
- task: Npm@1
inputs:
command: 'custom'
customCommand: 'run lint'
displayName: 'Lint checking'
这工作正常,直到 npm run lint 然后它失败。 但是找到缓存键并恢复缓存。 条件行的计算结果为 false,这也是正确的。
如果我强制 npm 安装,那么 lint 行会起作用。
你知道恢复缓存和强制安装 npm 有什么区别吗?
或者对如何让它发挥作用的任何想法?
【问题讨论】:
-
“失败”怎么办?给出错误?什么错误?在寻求帮助时,您需要提供尽可能多的具体详细信息。发布错误日志。
标签: npm azure-devops npm-install