【问题标题】:yaml file issue Unexpected value 'steps', "mapping values are not allowed in this context", trying to create jobs using templateyaml 文件问题 Unexpected value 'steps', “mapping values are not allowed in this context”,尝试使用模板创建作业
【发布时间】:2022-01-02 02:53:17
【问题描述】:

在我的主要 YAML 中

stages:
  - stage: ui_tests
    <.......>

  - stage: ui_remote_testing
    jobs:
      - template: status-template.yml
        parameters:
          polls: [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]

在我的 status-template.yml 中

parameters:
  - name: "polls"
    type: object
    default: { }

steps:
  -job: polling_job
    - ${{ each poll in parameters.polls }}:
      - task: PowerShell@2
        inputs:
          targetType: 'inline'
          script: |
            $global:testsCompleted = 0

我需要更改什么才能使模板作为作业运行

【问题讨论】:

    标签: azure-devops yaml azure-pipelines azure-pipelines-yaml cicd


    【解决方案1】:

    步骤在 Jobs 中,而不是相反,所以模板应该是:

    jobs:
    - job: polling_job
      steps:
      - ${{ each poll in parameters.polls }}:
        - task: PowerShell@2
          inputs:
            targetType: 'inline'
            script: |
              $global:testsCompleted = 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      相关资源
      最近更新 更多