Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

azure-pipelines - 使用参数化的模板来避免代码重复会导致错误消息:“期望序列”(Using parameterized templates to avoid code duplicates leads to error message: 'A sequence was expected')

For our build, I want to use a stage that is triggered for every push / pull request, with a limited number of parameter combinations in the build matrix.

(对于我们的构建,我想使用为每个推/拉请求触发的阶段,在构建矩阵中使用有限数量的参数组合。)

Another stage, which is executed nightly using a scheduled build, I want to use the full build matrix with all parameter combinations.

(另一个阶段是使用计划的构建每晚执行一次,我想将完整的构建矩阵与所有参数组合一起使用。)

Since Azure Pipelines does not support a compact representation of the build matrix , I would at least like to put the build matrix into a separate file, so that file is at least clearly arranged.

(由于Azure Pipelines 不支持生成矩阵的紧凑表示形式,因此我至少希望将生成矩阵放入一个单独的文件中,以便至少清楚地安排该文件。)

azure-pipelines.yml (the main file)

(azure-pipelines.yml (主文件))

stages:
  - stage: ci_build_on_default_pool
    jobs:
      - template: tools/azure-pipelines/azure-jobs.yml
        parameters:
          stage_name: ci_build_on_default_pool
          pool_definition:
            name: Default
          test_strategy:
            - template: tools/azure-pipelnes/ci-build-matrix.yml

  - stage: ci_build_on_azure_os_free_pool
    jobs:
      - template: tools/azure-pipelines/azure-jobs.yml
        parameters:
          stage_name: ci_build_on_azure_os_free_pool
          pool_definition:
            vmImage: 'ubuntu-latest'
          test_strategy:                
            - template: tools/azure-pipelnes/ci-build-matrix.yml

  # Special stage for midnight build:
  - stage: cron_build_on_azure_os_free_pool
    condition: eq(variables['Build.Reason'], 'Schedule')
    jobs:
      - template: tools/azure-pipelines/azure-jobs.yml
        parameters:
          stage_name: cron_build_on_azure_os_free_pool
          pool_definition:
            vmImage: 'ubuntu-latest'
          test_strategy:
              matrix:
                core:
                  parameter: core
                python:
                  parameter: python
                libraries:
                  parameter: libraries

azure-jobs.yml (file containing the definition of the build jobs)

(azure-jobs.yml (包含构建作业定义的文件))

parameters:
  pool_definition:
  stage_name:
  test_strategy: {}

jobs:
[ ... ]

- job: runOnAzure_test
  pool: ${{parameters.pool_definition}}
  container: flink-build-container
  strategy: ${{parameters.test_strategy}}
  steps:


ci-build-matrix.yml (default matrix definition shared across two stages)

(ci-build-matrix.yml (两个阶段共享的默认矩阵定义))

matrix:
  core:
    parameter: core
  python:
    parameter: python
  libraries:
    parameter: libraries

[ ... ]

The full source is available here .

(完整的资源在这里 。)

With these inputs, I'm getting the following error :

(通过这些输入,我得到以下错误 :)

/tools/azure-pipelines/azure-jobs.yml (Line: 60, Col: 13): A sequence was not expected

How can I resolve this?

(我该如何解决?)

  ask by Robert Metzger translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I recall encountering this issue when I first started using templates.

(我记得我第一次开始使用模板时遇到的这个问题。)

Im pretty sure it has to something to with the first step of a template has to be a task.

(我非常确定,模板的第一步一定要完成任务。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...