簡體   English   中英

嘗試在 Azure Devops 上的構建之間緩存 npm 安裝

[英]Trying to cache npm installs between builds on Azure Devops

我正在嘗試將我的管道配置為在構建之間緩存 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 運行 lint 然后它失敗。 但是找到緩存鍵並恢復緩存。 條件行評估為假,這也是正確的。

如果我強制安裝 npm,那么棉絨線就可以工作。

任何想法恢復緩存和強制安裝 npm 之間的區別是什么?

或者關於如何讓它發揮作用的任何想法?

感謝您的提示-我應該更具體。 基本上,這不適用於嘗試此操作的其他任何人。 這不是緩存 npm 安裝的方法:) 在構建之間似乎不是一個好方法。 You can cache the.npm folder but that doesn't really speed builds up much if at all - probably due to Azure caching npm registries and high network speeds internal to Azure

你的問題有點模糊,所以我有一個建議。 查看管道的變量。 看到 system.debug 變量了嗎? 將其設置為真。 現在,Azure 通常會顯示更多關於管道中發生的情況的信息。 如果 linting 失敗,也許你會找到更多信息。 現在用這里新發現的診斷來調整你的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM