Forum Discussion
Scaling CI/CD Pipelines with Azure DevOps- YAML Based Approach
Congratulations on the article, Laxman!
YAML templates do a great job in reusing pipelines, but I often encounter a problem with this common approach.
Imagine the scenario:
A company uses a Core repository with pipeline templates that are reused by several projects. This Core repository is maintained by the DevOps team, but there is also an Inner Source initiative. This allows teams to develop new features and integrate them into the Core, through PR.
In this scenario, what would be the best practices in relation to Core testing?
There is a proposal that suggests creating pipelines using custom tasks that encapsulate the entire logic of a stage, for example. The goal of this strategy is to be able to apply unit tests to these components. What do you think of this?
How to implement consistent tests on YAML templates? Especially in cases where there are inline script codes.
Hi Gabriel,
To my knowledge, Implementing consistent YAML Templates, especially when involving inline script code can be achieved using this practices.
1. If you have a custom task that installs dependencies, create a unit test to verify that the task installs the correct dependencies in the expected location.
2. we can divide our YAML templates into modular components making it easier to test each component in isolation. for example, If your YAML template has a deployment stage and a configuration stage, break them into separate tasks. This way, you can test each task independently to ensure they function correctly.
3. Integrate a testing framework like Jest or Mocha into your CI/CD pipeline. Write tests that automatically run when changes are pushed. For instance, test if your YAML pipeline correctly triggers on specific events.
4. Update YAML template to takes parameters for deployment environments, create tests that cover different configurations (e.g., staging, production). Confirm that the template adapts appropriately to each setting.
if we consider these options than i guess we can achieve what you are looking for.
Hope this helps you little.