我有一个CD管道,它构建一个项目(针对不同的环境多次),并将./dist
目录发布/保存为一个阶段。我可以下载每个环境并按预期在本地运行。
每个环境构建都是一个需要手动批准的阶段。这就是我迷路的地方。每个阶段显示被拖入阶段的正确工件,但是AzureStaticWebApp@0 -> app_location input
会导致“无法检测到此目录”。错误。
简单地说:在构建项目并将其保存为工件(我可以手动下载和验证)之后,我无法将构建的代码推送到Azure静态Web应用程序,因为它是找不到的。我试过多少次组合都没有效果。有什么建议吗?
我在使用模板,下面是静态Web应用程序模板
当该模板运行时,我可以看到作业在运行,并成功地使用此输出提取了正确的工件:
Successfully downloaded artifacts to /home/vsts/work/1/
Finishing: Download Artifact
但是AzureStaticWebApp@0
任务提供了以下错误:
App Directory Location: '/home/vsts/work/1/DEV' is invalid. Could not detect this directory. Please verify your deployment configuration file reflects your repository structure.
parameters:
- name: environment
default: development
type: string
- name: variableGroup
default: development-variables-group
type: string
jobs:
- deployment:
displayName: 'Deploy to'
environment: ${{parameters.environment}}
variables:
- group: ${{parameters.variableGroup}}
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:
- task: AzureStaticWebApp@0
inputs:
app_location: '$(Pipeline.Workspace)/DEV'
api_location: 'api'
output_location: 'dist'
skip_app_build: true
env:
azure_static_web_apps_api_token: $(deployment-token)
编辑
任务AzureStaticWebApp是否不能访问项目之外的任何内容?
- deployment:
displayName: 'Deploy to'
environment: ${{parameters.environment}}
variables:
- group: ${{parameters.variableGroup}}
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:
- checkout: self
submodules: true
# This step pulls down a complied site. E.g DEV/index.htm, ./images, staticwebapp.config.json
# That has an output like:
# Downloading DEV/index.html to /home/vsts/work/1/DEV/index.html
# Successfully downloaded artifacts to /home/vsts/work/1/
- download: current
artifact: DEV
- task: AzureStaticWebApp@0
inputs:
# I've tried many different values for app_location but all return back not found error
app_location: '/DEV'
api_location: 'api'
output_location: 'dist'
skip_app_build: true
env:
azure_static_web_apps_api_token: $(deploymenttoken)
发布于 2021-08-30 15:10:51
app_location
指定应用程序代码的根。该属性应指向回购中的某个位置。
查看这里的文档:https://learn.microsoft.com/en-us/azure/static-web-apps/publish-devops
还有,https://github.com/Azure/static-web-apps/issues/5#issuecomment-855309544
https://stackoverflow.com/questions/68985919
复制相似问题