【问题标题】:Azure static web site build pipeline -> blob uploadAzure 静态网站构建管道 -> Blob 上传
【发布时间】:2019-06-12 23:03:19
【问题描述】:

我有一个在 azure 中托管的 vue spa 应用程序。但是,在 Azure DevOps 中设置后,我无法让它作为构建管道运行

npm install 和 npm run build 完美运行,但是,将我的 dist 目录复制到我的 blob 存储的脚本失败。

这是我尝试过的方法和结果。有人有这方面的经验吗?

AzureFileCopy

- task: AzureFileCopy@3
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist'
    azureSubscription: '[my subscription details]'
    Destination: 'AzureBlob'
    storage: 'mystorageaccountname'
    ContainerName: '$web'

结果

##[section]Starting: AzureFileCopy
==============================================================================
Task         : Azure file copy
Description  : Copy files to Azure Blob Storage or virtual machines
Version      : 3.1.11
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
==============================================================================
##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM\2.1.0\AzureRM.psd1 -Global
##[warning]The names of some imported commands from the module 'AzureRM.Websites' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##[warning]The names of some imported commands from the module 'AzureRM' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM.Profile\2.1.0\AzureRM.Profile.psm1 -Global
##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -EnvironmentName AzureCloud
##[command] Set-AzureRmContext -SubscriptionId dc6a0ce7-adcd-49fd-ad85-e1c082994145 -TenantId ***
Uploading files from source path: 'D:\a\1\s\dist' to storage account: 'mystorageaccountname' in container: '$web' with blob prefix: ''
##[command] & "AzCopy\AzCopy.exe" /Source:"D:\a\1\s\dist" /Dest:"https://mystorageaccountname.blob.core.windows.net/`$web" /@:"D:\a\_temp\ead7e7cf-0b6e-4b16-928f-c84cf3e3a7ab" /XO /Y /SetContentType /Z:"AzCopy" /V:"AzCopy\AzCopyVerbose_ae491d97-a7a8-44e6-b7b0-4b932a5e6c08.log" /S
[2019/06/13 00:31:08][ERROR] Error parsing source location "D:\a\1\s\dist": Failed to enumerate directory D:\a\1\s\dist\ 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.
##[error]Upload to container: '$web' in storage account: 'mystorageaccountname' 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
##[section]Finishing: AzureFileCopy

【问题讨论】:

  • 放一个 cmd 并尝试在文件复制任务之前执行一个 dir 并检查 dist 文件夹是否在 $(System.DefaultWorkingDirectory) 中创建。很有可能是找不到 dist 文件夹。
  • 您能分享您的npm run build 步骤吗?可能 dist 文件夹存在于其他地方。
  • 嘿 Dhruv,运行“dir”的建议让我找到了解决方案。谢谢你的提示。请参阅下面的答案!

标签: azure azure-storage azure-pipelines


【解决方案1】:

感谢建议我运行“目录”的评论。它实际上没有用。经过检查,以下命令甚至没有构建应用程序。

- script: |
    npm install
    npm run build
    dir
  displayName: 'npm install and build'

我认为这是因为我将代理更改为在 windows 上运行(我之前发现 AzureFileCopy 仅在 windows 上运行)并且 windows 代理不允许像 ubuntu 代理那样堆叠脚本。所以我将安装和构建拆分为单独的任务,现在它只运行动词警告。这是工作脚本:

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- script: |
    npm run build
  displayName: 'npm run build'

- script: |
    dir
  displayName: 'list cwd contents (verify build)'

- task: AzureFileCopy@3
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist'
    azureSubscription: '[my subscription details]'
    Destination: 'AzureBlob'
    storage: 'mystorageaccountname'
    ContainerName: '$web'

【讨论】:

    猜你喜欢
    • 2020-12-23
    • 2021-05-05
    • 1970-01-01
    • 2016-08-15
    • 2020-05-17
    • 1970-01-01
    • 2019-09-19
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多