I am writing an Azure Pipeline framework in YAML which will be used on multiple projects, each with its own environment variables. I am now wondering whether the best option is to define these variables in variable groups or to use YAML templates.
The requirements are as follows
- Values should not bleed between projects.
- Values do not need to be versioned.
- It is an advantage if values are easy to access and change.
- The variable sets need to have the same structure for every project, i.e. group and variable names must follow a specific pattern.
- It must be possible to detect whether a variable definition is missing.
Both solutions seem to conflict with the requirements.
While variable groups naturally satisfy requirements 1-3, requirements 4 and 5 seem a little more complicated. For requirement 4, it is up to the developer to make sure the structure remains the same between projects, which can become a tedious and error-prone activity when the collection of groups grows. Regarding requirement 5, I guess it is possible to write a template to make sure all the necessary variables are defined, although it seems to me this leads to bloat.
What I have in mind with this solution is to create unfilled YAML templates to define the required values, guiding the developers. This way, they will get syntax errors if they forget some definitions. Hence requirements 1, 4, and 5 are satisfied. The last two are less clear, however. For requirement 2, versioning is not preferred but is not an issue either. And regarding requirement 3, with this solution, users will have to have a basic understanding of the repository and YAML syntax to read and change values.
What is the recommended solution in this scenario? Are there best practices guidelines to follow, or perhaps some other solution to this problem? Help is much appreciated!