根據任務的檔案,我們為Cache@2任務設定了這個key:
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json | package.json'
# etc.
就在此之前,我們已經安裝了 Node:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
如何將代理上的節點版本用作key? 有沒有類似的東西Agent.NodeVersion,我在哪里可以找到關于可用變數的檔案?
uj5u.com熱心網友回復:
本來希望使用內置變數,但現在我解決了它:
variables:
NodeVersionSpec: 16.x
- task: NodeTool@0
inputs:
versionSpec: $(NodeVersionSpec)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
key: 'npm | "$(NodeVersionSpec)" | "$(Agent.OS)" | package-lock.json | package.json'
restoreKeys: |
npm | "$(Agent.OS)"
npm
path: $(npm_config_cache)
displayName: Cache npm
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/443202.html
標籤:天蓝色 npm 天蓝色的devops 持续集成 yaml
