sonic-buildimage/.azure-pipelines/azure-pipelines-job-groups.yml

58 lines
1.9 KiB
YAML
Raw Normal View History

parameters:
- name: 'preSteps'
type: stepList
default: []
- name: 'buildSteps'
type: stepList
default: []
- name: "postSteps"
type: stepList
default: []
- name: 'jobGroups'
type: object
default: []
- name: 'jobVariables'
type: object
default: {}
- name: 'scriptEnv'
type: object
default: ''
- name: 'timeoutInMinutes'
type: 'number'
default: 900
- name: 'jobFilters'
type: object
default: ''
jobs:
- ${{ each jobGroup in parameters.jobGroups }}:
- ${{ if or(eq(parameters.jobFilters, ''), containsValue(parameters.jobFilters, jobGroup.name), endswith(variables['Build.DefinitionName'], format('.{0}{1}', jobGroup.name, jobGroup.extName))) }}:
- job: ${{ replace(format('{0}{1}', jobGroup.name, jobGroup.extName), '-', '_') }}
${{ each pair in jobGroup }}:
${{ if not(in(pair.key, 'job', 'name', 'extName', 'variables', 'steps', 'script', 'scriptEnv')) }}:
${{ pair.key }}: ${{ pair.value }}
${{ if eq(jobGroup.timeoutInMinutes, '') }}:
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
variables:
GROUP_NAME: ${{ jobGroup.name }}
GROUP_EXTNAME: '${{ jobGroup.extName }}'
GROUP_NAMES: ${{ join(',', parameters.jobGroups.*.name ) }}
${{ if ne(jobGroup.variables, '') }}:
${{ jobGroup.variables }}
${{ each para in parameters.jobvariables }}:
${{ if eq(jobGroup.variables[para.key], '') }}:
${{ para.key }}: ${{ para.value }}
steps:
- ${{ parameters.preSteps }}
- ${{ if ne(jobGroup.script, '') }}:
- script: |
${{ jobGroup.script }}
env:
${{ if ne(parameters.scriptEnv, '') }}:
${{ parameters.scriptEnv }}
displayName: 'JobScript'
- ${{ if ne(jobGroup.steps, '') }}:
- ${{ jobGroup.steps }}
- ${{ parameters.buildSteps }}
- ${{ parameters.postSteps }}