TL; DR
Is there any way that I can use JSON variable substitution with default Release variables in VSTS?
Description
With VSTS, I can use JSON variable substitution to set values in an appsettings.json file at release time.  For example, with an appsettings.json file that looks like this:
{    
  "ConnectionStrings": {
    "DM_ADJ": "placeholder",
    "DM_SALES": "placeholder"
  },
  // And so on.  Placeholders get replaced
}
I can define a Release variable in VSTS called ConnectionStrings.DM_ADJ, and the value I provide there will replace "placeholder" in the corresponding JSON line.
Now, I would also like to use some of the default Release variables in my app's configuration.  For example, there are default Release variables called Release.DefinitionName and Release.DefinitionId.  I thought that I could substitute them into an appsettings.json config section like below, but unfortunately, when the Release completes, the "placeholder" strings do not get replaced.  Am I missing something?
{
  "Release": {
    "DefinitionName": "placeholder",
    "DefinitionId": "placeholder",
  }
  // And so on.  Placeholders do not get replaced
}
                Share variables between Tasks across the Jobs (of the same Stage) We need to use the isOutput=true flag when you desire to use the variable in another Task located in another Job.
To use a variable group, open your pipeline. Select Variables > Variable groups, and then choose Link variable group. In a build pipeline, you see a list of available groups. In a release pipeline, for example, you also see a drop-down list of stages in the pipeline.
This is an expected behavior since it excludes the build/release's system definition variables:

If you want to use the system definition variables in the json file, creating a custom variable and set the value to system defined variable like following instead of using system defined variable directly:
 
you need to specify the json file you want to change the values

then you just need to create a variable with the path you want to change. for example i want to change the property Version

so, i need to create a variable with this name:
Aplicacao.Version

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With