![](/img/trans.png)
[英]Unable to run Azure pipeline "A task is missing. The pipeline references a task called 'Cache'
[英]Getting 'A task is missing. The pipeline references a task called 'Cache'.' error in Azure Pipeline
我正在嘗試在 Azure Pipeline YAML 中緩存我的 npm 包。 我使用了來自 Microsoft 的此代碼: https : //docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#nodejsnpm
這是我的 YAML 文件的一部分:
steps:
- task: NodeTool@0
displayName: 'Use Node 12.x'
inputs:
versionSpec: 12.18.3
checkLatest: false
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: WebApp
verbose: false
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: npm | "$(Agent.OS)"
path: $(npm_config_cache)
displayName: Cache NPM packages
當我運行管道時,它失敗並顯示以下消息:
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com.
我嘗試從 Microsoft Marketplace 安裝緩存任務,但它不可用。 我正在使用帶有 6 月更新的 Azure DevOps Server 2019。 緩存任務尚未棄用,應根據此頁面與我的 Azure DevOps 服務器版本一起使用: https : //docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/cache?view =azure-devops 。 如何安裝緩存任務?
更新:
我在 Microsoft 開發者論壇上找到了一篇涵蓋相同問題的帖子: https : //developercommunity.visualstudio.com/content/problem/1092245/cache-task-not-available-on-azure-devops-server.html 。 顯然,緩存任務目前在 Azure DevOps Server 2019 上不可用。我必須尋找解決方法。 談論荒謬。 Microsoft 不提供緩存任務,也沒有在他們的網站上放置任何關於它的內容。
如果您使用自托管代理。 您可以在管道中添加checkout
步驟並將clean
屬性設置為false
(如果未指定,則默認為true
)。 這樣就不會為下次構建清除源文件夾中已安裝的依賴項。 它將加速 npm install 任務。 見下文:
steps:
- checkout: self
clean: false
- task: NodeTool@0
displayName: 'Use Node 12.x'
inputs:
versionSpec: 12.18.3
checkLatest: false
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: WebApp
verbose: false
在這里查看更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.