In AzureDevops, trying to run a yaml file to trigger a powershell script - how can i assign different environment values to script so that it runs for all environment.
parameters:
- name: environmentName
type: string
default: 'PROD'
- name: azureSubscription
type: string
default: 'ABC-Prod'
- job: ABC
variables:
- group: 'ABC-${{ parameters.environmentName }}'
steps:
- task: AzurePowerShell@5
inputs:
#azureSubscription: 'ABC-nonprod-dev'
scriptType: 'FilePath'
azurePowerShellVersion: 'LatestVersion'
scriptPath: 'src/databricks/ABC.ps1'
displayName: 'ABC Databrick Job'
Now this job needs to be run in DEV, UAT and PROD and azureSubscription - 'ABC-nonprod-dev','ABC-nonprod-uat' and 'ABC-prod'
How we can run a loop in powershell so that ABC.ps1 script can run for all 3 environments
To create foreach you can use expressions combined with 'each' keyword providing list of environments as a object
parameters:
- name: environments
type: object
default:
- dev
- prod
steps:
- ${{ each value in parameters.environments}}:
- script: echo ${{ value }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.