Reputation: 133
I have multiple azure pipelines which have similar azure YAML files. The parameters defined in those YAML files are repetitive. Can it be inherited, if I define those parameters in a common YAML file?
##saving-account.yml
name: savings
parameters:-name:run_mode type:string default:custom -name:app_version type:string default:uatstages:
-stage:RunScript jobs: -job: script steps: script -script: /mylocation/savings.sh -r ${{parameters.run_mode }} -a ${{ parameters.app_version}}
##loans-account.ymland this is true for other scripts too. So, if we see both the examples, the parameters remain the same, and the jobs->steps->script file changes. Can I pull out the parameters from the individual files and put them in a common file and then extend that file somehow in other files. I have seen this example,
name: savings
parameters:-name:run_mode type:string default:custom -name:app_version type:string default:uatstages: -stage:RunScript jobs: -job: script steps: script -script: /mylocation/loans.sh -r ${{parameters.run_mode }} -a ${{ parameters.app_version}}
Upvotes: 0
Views: 1756
Reputation: 2978
Alternate option is to use a variable yaml template under the jobs. This template can reference the same file between pipelines to reduce redundancies. Would be switching ${{parameters.}}
to ${{variables.}}
Can even switch the variable group depending on a parameter, in this case environment.
Would look like:
jobs:
-job: script
variables:
- template: ../variables/${{ parameters.environmentName }}.yml
steps: script
- script: /mylocation/loans.sh -r ${{variables.run_mode }} -a ${{ variables.app_version}}
The variable.yml file might look like:
variables:
-name:run_mode
type:string
value:custom
-name:app_version
type:string
value:uat
Doesn't exactly fit your ask but is an alternative to having the same values defined multiple times.
This variable file can be centrally located in another repo to.
Upvotes: 2
Reputation: 40779
Am afraid that I have a short answer. You cannot do that. You cannot reuse common parametrs. You can just nest temlates but actually nothing more.
Upvotes: 0