1

我正在尝试使用作业模板触发一个或多个下游作业。我的定义总结:

- job-template:
    name: something-{app}-build
    project-type: freestyle
    defaults: global
    block-downstream: true
    scm:
      - git:
          url: url
          branches:
            - 'master'
          excluded-users:
            - Jenkins
    builders:
      !include: templates/build-and-publish.yml
    publishers:
      - postbuildscript:
          builders:
            !include: templates/docker-build-and-push-to-ecr.yml
          script-only-if-succeeded: True
          mark-unstable-if-failed: True
      - trigger-parameterized-builds:
        - project: 'deploy-dev-ecs-service'
          condition: SUCCESS
          predefined-parameters: |
                                  service={app}
                                  envparams={envparams}

- project:
    name: release-to-ecr
    type: app
    envparams: ''
    app:
      - app-1
      - app-2:
      - app-3:
          envparams: 'FOO=42'
    jobs:
      - 'something-{app}-build'

现在这可行,但我需要根据应用程序触发不同的下游作业。这意味着使用多个参数多次触发 deploy-dev-ecs 服务。例如:

app:
    - app-1:
         - project: deploy-dev-ecs-service
           service: 'app-1'
           envparams: 'foo=bar'
    - app-2:
         - project: deploy-dev-ecs-service
           service: 'app-2.2'
           envparams: 'x=2'
         - project: deploy-dev-ecs-service               
           service: 'app-2.3'
           envparams: 'x=3'

本质上,我需要根据
项目参数控制触发哪些下游作业。有没有办法做到这一点?

4

0 回答 0