首页 > 解决方案 > Azure DevOps 管道:Azure 复制文件步骤 V4 错误 - 找不到指定的文件夹

问题描述

我打算使用 Azure DevOps 管道将故事书的静态版本部署到 Azure 云存储 blob 容器。

由于图像有时更具描述性: 什么是绝对路径

SourcePath(或上图中的 Source)需要是要复制到 blob 的文件/文件夹的绝对路径。我提到: https ://github.com/microsoft/azure-pipelines-tasks/edit/master/Tasks/AzureFileCopyV4/README.md https://docs.microsoft.com/en-us/azure/devops/pipelines /build/variables?tabs=yaml&view=azure-devops 和其他各种来源。无论我尝试使用什么预定义变量,我总是看到相同的错误:

failed to perform copy command due to error: cannot start job due to error: cannot scan the path \\?\D:\a\1\dist-storybook, please verify that it is a valid.

这就是我到目前为止所尝试的:

  - task: AzureFileCopy@4
    inputs:
#      SourcePath: '$(Build.Repository.LocalPath)/dist-storybook'
#      SourcePath: '$(Build.SourcesDirectory)/dist-storybook'
      SourcePath: '$(Agent.BuildDirectory)/dist-storybook'
#      SourcePath: '$(System.DefaultWorkingDirectory)/dist-storybook'
      azureSubscription: 'xxx'
      Destination: 'AzureBlob'
      storage: 'xxx'
      ContainerName: 'storybook'

在您使用评论之前检查 dist-storybook 文件夹是否存在以及我是否已验证。

是的,它存在。在我尝试 Azure File Copy v4 任务之前,我使用的是AzureRmWebAppDeployment带有此参数的任务:(packageForLinux: '$(System.DefaultWorkingDirectory)/dist-storybook'它部署到 Azure App Service [但在 Storybook 的情况下,这是一个矫枉过正,因为生成的 Storybook 由静态文件组成,不需要服务器运行] ) 并且它正在成功部署 Storybook。因此,dist-storybook在管道的上一步中正确生成了。

有人有任何线索吗?

更新:

在微软开发者论坛上获得一些帮助后:

https://developercommunity.visualstudio.com/content/problem/1203833/azure-file-copy-source-requires-absolute-path.html

我开始使用带有预定义系统变量的任务的 v3 (AzureFileCopy@3) $(Build.Repository.LocalPath)(我已经使用 v4 [AzureFileCopy@4] 失败了)

这是完整的任务:

  - task: AzureFileCopy@3
    inputs:
      SourcePath: '$(Build.Repository.LocalPath)/dist-storybook/*'
      azureSubscription: 'xxx'
      Destination: 'AzureBlob'
      storage: 'xxx'
      ContainerName: 'storybook'

现在我得到这个错误:

2020-09-30T09:19:03.1646485Z ##[section]Starting: AzureFileCopy
2020-09-30T09:19:03.1870156Z ==============================================================================
2020-09-30T09:19:03.1871285Z Task         : Azure file copy
2020-09-30T09:19:03.1872336Z Description  : Copy files to Azure Blob Storage or virtual machines
2020-09-30T09:19:03.1873312Z Version      : 3.175.2
2020-09-30T09:19:03.1874422Z Author       : Microsoft Corporation
2020-09-30T09:19:03.1876194Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
2020-09-30T09:19:03.1877411Z ==============================================================================
2020-09-30T09:19:06.0053519Z ##[command]Import-Module -Name C:\modules\azurerm_6.13.1\AzureRM\6.13.1\AzureRM.psd1 -Global
2020-09-30T09:19:29.9367823Z ##[command]Clear-AzureRmContext -Scope Process
2020-09-30T09:19:31.1812482Z ##[command]Clear-AzureRmContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
2020-09-30T09:19:32.3448727Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
2020-09-30T09:19:34.2134374Z ##[command] Set-AzureRmContext -SubscriptionId 5a6f9ac1-3fc5-4ecc-9909-7c1f7be55b1f -TenantId ***
2020-09-30T09:19:41.8630229Z Uploading files from source path: 'D:\a\1\s\dist-storybook\*' to storage account: 'stdesignsystemdevuksouth' in container: 'storybook' with blob prefix: ''
2020-09-30T09:19:41.9074144Z ##[command] & "AzCopy\AzCopy.exe" /Source:"D:\a\1\s\dist-storybook\*" /Dest:"https://stdesignsystemdevuksouth.blob.core.windows.net/storybook" /@:"D:\a\_temp\9a9dd952-202a-4851-91ed-e27a062f8f4a" /XO /Y /SetContentType /Z:"AzCopy" /V:"AzCopy\AzCopyVerbose_a1f6be33-1856-4036-98e1-d6c9c5a151af.log" /S
2020-09-30T09:19:42.8784330Z [2020/09/30 09:19:42][ERROR] Error parsing source location "D:\a\1\s\dist-storybook\*": Failed to enumerate directory D:\a\1\s\dist-storybook\*\ with file pattern *. The system cannot find the path specified. (Exception from HRESULT: 0x80070003) For more details, please type "AzCopy /?:Source" or use verbose option /V.
2020-09-30T09:19:43.1065203Z ##[command]Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
2020-09-30T09:19:43.9220995Z ##[command]Clear-AzureRmContext -Scope Process -ErrorAction Stop
2020-09-30T09:19:44.4426511Z ##[error]Upload to container: 'storybook' in storage account: 'stdesignsystemdevuksouth' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-09-30T09:19:44.5187191Z ##[section]Finishing: AzureFileCopy

标签: azureazure-devopsazure-pipelinesazure-pipelines-build-task

解决方案


推荐阅读