Azure DevOps 管道 AZ CLI 上传批处理不推送文件
Azure DevOps Pipeline AZ CLI upload-batch not pushing files
我正在尝试为我们的单页 React 应用程序建立一个简单的 CI/CD 流程。 CI 已设置为 npm 构建 React 应用程序并将构建存档 (.zip) 发布到 $(Build.ArtifactStagingDirectory).
然后触发 CD 过程以从工件 .zip 文件中提取构建并利用 AZ CLI 任务将文件推送到托管静态网站的 Azure Blob 存储帐户。
部署成功完成,但是没有文件发布到 blob 存储帐户。我假设它与 AZ CLI 命令的 --source 标志有关,并尝试使用 $(Build.DefaultWorkingDirectory)/$(Build.BuildId) 环境变量作为源。
然而,这导致部署失败并出现以下错误。
The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet
我不确定 DevOps 目录的结构或 AZ CLI 如何通过 --source 标志与它们交互,但我将不胜感激任何提示或建议。
第一:参考the DevOps directories structure.
其次:您可以检查 DevOps 中的工件:
您将看到如下页面。将工件下载到本地以检查详细信息:
最后,如果您对此还很陌生,请观看有关 deploy React apps to Azure 的视频。
The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet
由于您使用 CD Process 启动 azure cli 部署,看来您使用的是 Release Pipeline.
根据我的测试,我可以在 Release Pipeline 中重现这个问题。
这个问题的根本原因是变量 Build.DefaultWorkingDirectory
无法在 Release Pipeline 中使用。
此变量只能在构建管道(CI 进程)中使用。
要解决这个问题,您可以尝试使用变量:$(system.DefaultWorkingDirectory)
.
提取文件任务
Azure CLI 脚本示例:
az storage blob upload-batch --account-name $(Name) --account-key $(key) -s $(system.DefaultWorkingDirectory)/$(build.buildid) --pattern * -d xxx
这是一篇关于 the variables in Release Pipeline 的文档。
另一方面,除了Azure Cli脚本,你还可以直接使用Azure file copy task。会更方便。
我正在尝试为我们的单页 React 应用程序建立一个简单的 CI/CD 流程。 CI 已设置为 npm 构建 React 应用程序并将构建存档 (.zip) 发布到 $(Build.ArtifactStagingDirectory).
然后触发 CD 过程以从工件 .zip 文件中提取构建并利用 AZ CLI 任务将文件推送到托管静态网站的 Azure Blob 存储帐户。
部署成功完成,但是没有文件发布到 blob 存储帐户。我假设它与 AZ CLI 命令的 --source 标志有关,并尝试使用 $(Build.DefaultWorkingDirectory)/$(Build.BuildId) 环境变量作为源。
然而,这导致部署失败并出现以下错误。
The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet
我不确定 DevOps 目录的结构或 AZ CLI 如何通过 --source 标志与它们交互,但我将不胜感激任何提示或建议。
第一:参考the DevOps directories structure.
其次:您可以检查 DevOps 中的工件:
最后,如果您对此还很陌生,请观看有关 deploy React apps to Azure 的视频。
The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet
由于您使用 CD Process 启动 azure cli 部署,看来您使用的是 Release Pipeline.
根据我的测试,我可以在 Release Pipeline 中重现这个问题。
这个问题的根本原因是变量 Build.DefaultWorkingDirectory
无法在 Release Pipeline 中使用。
此变量只能在构建管道(CI 进程)中使用。
要解决这个问题,您可以尝试使用变量:$(system.DefaultWorkingDirectory)
.
提取文件任务
Azure CLI 脚本示例:
az storage blob upload-batch --account-name $(Name) --account-key $(key) -s $(system.DefaultWorkingDirectory)/$(build.buildid) --pattern * -d xxx
这是一篇关于 the variables in Release Pipeline 的文档。
另一方面,除了Azure Cli脚本,你还可以直接使用Azure file copy task。会更方便。