Usage of variables files
This example explains how to define default values using variables.ospp files, including nested variable files and per-owner overrides.
Use a
variables.osppfile to provide a default value to an owner viavariablesFiles.Override a variable locally inside the owner using
templateVariables.Chain a sub-variables file to supply additional variables from a nested
variables.ospp.
git checkout origin/osp-web-configuration .
git checkout origin/osp-variables-configuration .
git checkout origin/example-inheritance-template-variables-file .
Steps
1. Create a value and his owner
The default is directly extracted from the variables.ospp.
root/final/value.ospp
{
"name": "Example value",
"description": "Example value",
"type": "TEXT"
}
root/final/owner.variables
{
"moduleId": "modules.variables.variables-1",
"default": "${default-value}",
"variablesFiles": [
"root.variables"
]
}
root/variables/variables.ospp
{
"variables": {
"default-value": "My content"
},
"variablesFiles": [
"root.variables.sub"
]
}
Which result in the following owner.
2. Redefine the default value inside the owner
The default is overridden by the locally define one.
root/redefine/value.ospp
{
"name": "Example value",
"description": "Example value",
"type": "TEXT"
}
root/redefine/owner.variables
{
"moduleId": "modules.variables.variables-1",
"default": "${default-value}",
"variablesFiles": [
"root.variables"
],
"templateVariables": {
"default-value": "My new content"
}
}
root/variables/variables.ospp
{
"variables": {
"default-value": "My content"
},
"variablesFiles": [
"root.variables.sub"
]
}
Which result in the following owner as the default-value define on the root.redefine/owner.ospp is overriding the one define on root.variables/variables.ospp.
3. Use variables from a sub variables file
The default is overridden by the locally define one and add a new variable.
root/sub-variables/value.ospp
{
"name": "Example value",
"description": "Example value",
"type": "TEXT"
}
root/sub-variables/owner.variables
{
"moduleId": "modules.variables.variables-1",
"default": "${default-value}",
"variablesFiles": [
"root.variables"
],
"templateVariables": {
"default-value": "My new content is [${content}]"
}
}
root/variables/variables.ospp
{
"variables": {
"default-value": "My content"
},
"variablesFiles": [
"root.variables.sub"
]
}
root/variables/sub/variables.ospp
{
"variables": {
"content": "A message"
}
}
Which result in the following owner as the default-value define on the root.sub-variables/owner.ospp is overriding the one define on root.variables/variables.ospp and use content define on root.variables.sub/variables.ospp.