azure - Azure DevOps Pipeline 上的 YAML 解析器错误

标签 azure yaml azure-pipelines-release-pipeline pyyaml azure-pipelines-yaml

我在我的 azure Devop 管道上遇到以下错误,它似乎与参数循环有关,但尽管以多种不同的方式编写脚本,我似乎无法摆脱它。 YAML 验证器和我的 YAML linter 未检测到问题。

/azure-pipelines.yml(行:1,列:12):意外值“”

下面是我的代码,它也使用了一个模板,我将把它包含在它下面。

azure-pipelines.yml

parameters:
steps:
- ${{ each project in parameters.projects }}:
  - task: UsePythonVersion@0
    displayName: 'Setting python version to 3.7'
    inputs:
      versionSpec: '3.7'
      architecture: 'x64'

  - script: |
      pushd '$(System.DefaultWorkingDirectory)/${{ project }}'
      pip install -r requirements.txt
    displayName: 'Install prerequisites'

  - task: ArchiveFiles@2
    displayName: 'Archive files'
    inputs:
      rootFolderOrFile: '$(System.DefaultWorkingDirectory)/${{ project }}'
      includeRootFolder: false
      archiveFile: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'

  - task: PublishBuildArtifacts@1
    inputs:
      PathtoPublish: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'
      artifactName: 'drop'

  - task: AzureResourceManagerTemplateDeployment@3
    displayName: 'ARM Template deployment: Resource Group scope'
    
    inputs:
      azureResourceManagerConnection: $(serviceConnectionName)
      subscriptionId: $(subscriptionId)
      resourceGroupName: $(resourceGroupName)
      location: $(resourceGroupLocation)
      csmFile: 'deployment_template.json'
      overrideParameters: '-appName ${{ project }} -storageAcctName $(storageAcctName)  -hostingPlanName $(hostingPlanName)'

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: $(serviceConnectionName)
      appType: functionAppLinux
      appName: ${{ project }}
      package: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'

模板-deploy-functions.yml

trigger:
  - main

variables:
  - group: 'AzFunctionsAppVariableGroup'
    
pool:
  vmImage: ubuntu-18.04
  
steps:
- template: azure-pipelines.yml
  parameters:
    projects:
    - ProjectName1

最佳答案

如果我将你的 azure-pipelines.yml 放入 Azure DevOps 中的管道编辑器中,它会用警告标记 parameters: 的行结尾

"Incorrect type. Expected "array"."

到目前为止,我还没有在管道上使用模板,但是来自 MS doc page ,似乎您需要像这样指定要传递的参数:

#azure-pipelines.yml

parameters:
- name: projects
  type: object #object, since you are passing a list of strings
steps:
- ${{ each project in parameters.projects }}:
#...

关于azure - Azure DevOps Pipeline 上的 YAML 解析器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71324487/

相关文章:

amazon-web-services - 部署 efs 堆栈时出现以下错误

c# - 在 C# 中合并 YAML

azure - 如何将文件从Azure文件存储复制到发布管道TFS中的Azure VM?

azure-devops - VSTS 扩展 - 获取构建 URL

spring-boot - Spring Boot 2.7.8 或 3.x 升级 - Tomcat HTTP 状态 404 - 在 Azure 上找不到

python - 在 Azure 上运行 .exe

angular - Azure Devops 将 Angular 应用程序部署到静态 Web 应用程序

azure - 如何备份我的 Windows Azure 表存储?

python - 自动 Ansible 文档如何工作?

azure - (Azure DevOps) 命令行脚本 .exe 控制台消息在日志中不可见