Based on the documentation for the Cache@2
task we set this key
for the task:
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json | package.json'
# etc.
Just before that we've installed Node with:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
How can I use the version of Node on the Agent as a part of the key
? Is there something like Agent.NodeVersion
, and where could I find the documentation on available variables?
CodePudding user response:
Would've preferred to use a built-in variable, but for now I solved it with:
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