Calum Harrison logo
  • Home 
  • Tags 
  • About Me 
  1. Home
  2. Posts
  3. 3 tips for YAML Azure pipelines 🚀

3 tips for YAML Azure pipelines 🚀

Posted on November 17, 2024  (Last modified on November 29, 2024) • 2 min read • 379 words
ALM   Azure DevOps   YAML  
ALM   Azure DevOps   YAML  
Share via
Calum Harrison
Link copied to clipboard

On this page
  • 1)Parameters
  • 2) Loops
  • 3) Comments
  • Conclusion
3 tips for YAML Azure pipelines 🚀
Photo by Richard Gatley on unsplash

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.

  Note

The examples in this blog will be based on Power Platform pipelines.

Image of parameters, the values refer to variables set inside a variable group. The solution name is the logical name in the Dataverse environment.
Image of parameters, the values refer to variables set inside a variable group. The solution name is the logical name in the Dataverse environment.
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.

  Note

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 each 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.

Image of comments for a YAML pipeline.
Image of comments for a YAML pipeline.

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!

 Availability monitoring for Power Pages 🌍
Be transparent with end users by using a maintenance page 
On this page:
  • 1)Parameters
  • 2) Loops
  • 3) Comments
  • Conclusion
Follow me on LinkedIn

 
Copyright © 2025 Calum Harrison. | Powered by Hinode.
Calum Harrison
Code copied to clipboard