I am currently building a pipeline that will have a list of parameters, which will then pass those values to be used by child pipelines.
Main pipeline:
trigger: none
parameters:
- {name: 'location', type: string, default: 'eastus2', values: ['eastus2', 'centralus'], displayName: 'Resource group location'}
- {name: 'sqlDBAutoPauseDatabase', type: string, default: 'ooi', values: ['ooi', 'poembi'], displayName: 'SQL DB Autopause - Target database name'}
- {name: 'sqlDBAutoPauseAction', type: string, default: 'Enable', values: ['Enable', 'Disable'], displayName: 'SQL DB Autopause - Action to perform'}
- {name: 'sqlDBAutoPauseDelay', type: number, default: 60, values: [60, -1], displayName: 'SQL DB Autopause - Autopause delay time'}
stages:
- stage: 'Autopause'
jobs:
- template: '/cicd/pipelines/ooi/iac/ooi-sqldb-autopause.yaml'
parameters:
parent:
${{ insert }}: ${{ parameters }}
First child pipeline to run:
parameters:
- {name: parent, type: object, default: {}}
jobs:
- deployment: 'deploymentName'
environment: 'OOI-${{parameters.parent.envName}}'
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
inputs:
azureSubscription: '$(ADO_Connection)'
azurePowerShellVersion: 'LatestVersion'
ScriptType: 'InlineScript'
Inline: |
Set-AzSqlDatabase `
-ResourceGroupName $(ResourceGroupName) `
-DatabaseName ${{parameters.parent.sqlDBAutoPauseDatabase}} `
-ServerName $(ServerShort) `
-AutoPauseDelayInMinutes ${{parameters.parent.sqlDBAutoPauseDelay}}
This works fine however, this means I would have to switch all the required pipelines I need to run to be a template file. I was wondering if there was another way to pass down these parameters to child pipelines? I've been looking into other options like variable groups and using the REST API.