3 tips for YAML Azure pipelines ๐

1) Parameters
Parameters allow you to pass values to pipelines, for instance, you can use a parameter to pass the solution names that you want to deploy.
The examples in this blog will be based on Power Platform pipelines.
parameters:
- name: Demo_Solutions
displayName: "Demo Solutions"
type: object
default:
- $(MainSolution)
- $(FlowSolution)
The benefit of using parameters is that it makes pipelines more dynamic, if you want to only build an artifact for a particular solution you can do this easily by just removing the other variables that refer to the other solutions.
An artifact is usually a collection of files that you wish to deploy in a release pipeline.
However, to achieve the above we need to use the {{< mark >}}each{{< /mark >}} keyword expression to loop through tasks.
2) Loops
By using loops we can repeat tasks for each value present in the parameter object. For example, following the solutions parameter example, we can use this to loop common tasks such as exporting or incrementing solutions in a build pipeline. Instead of having a task per solution, we can reduce it to just one task thanks to using a loop.
# Increment solution
- ${{ each solution in parameters.Demo_Solutions }}:
- task: PowerPlatformSetSolutionVersion@0
inputs:
authenticationType: 'PowerPlatformSPN'
PowerPlatformSPN: '$(Demo-DEV-SC)'
SolutionName: '${{ solution }}'
SolutionVersionNumber: '$(Build.BuildNumber)'
displayName: "Increment ${{ solution }} version number"
condition: succeeded()
enabled: true
In the example above as we have two solutions in the parameter, there will be two tasks that increment the solution version number.
3) Comments
This might not be a shocking tip but by being able to add multi-line comments to YAML, allows you to provide a good overview of the pipeline structure. With classic pipelines, you don't have the option for this and it's a shame as comments can go a long way when used appropriately.
Conclusion
So we have gone through a couple of tips for when you are building YAML pipelines but there will be many more so feel free to share them so that we can all build quality pipelines.
Have a great day!
๐ If you liked this then please sign up to my newsletter that will notify you once a new blog comes out.






