Reputation: 5385
In my Xamarin.Forms application (that supports iOS, Android, UWP), I have a config.json file that defines some variables, e.g.
{ "HideExperimentalFeature": false }
Is it possible in the AzureDevops pipeline to inject a value for a variable based on stage, e.g. QA or Production? E.g. for QA it can be set to false, and for Production true. Is it possible to do it using user interface?
Upvotes: 0
Views: 580
Reputation: 962
Yes, you can use Replace Tokens
extension.
in config.json
file just add key markers, and tell the extension which files should be scanned for replacement.
{
"ConnectionStrings": {
"BloggingDatabase": "#{connection_string}#"
},
{ "HideExperimentalFeature": #{HideExperimentalFeature}# }
}
connection_string
will be replaced with proper value based on stage. Also, you can use Release
stage which means "use it everywhere". What is more, you can you Release + stage_x
, and then Release
will be used as default, and stage_x
will override it on its stage.
Consider Missing variable behavior
set as Fail pipeline
due to the fact, Log Warn
is usually not noticed in the woods of logs.
Also, Azure DevOps variables nature allows you using Settable as release time
option next to the variable definition. Then, you can pass the value
Upvotes: 1
Reputation: 46
You can replace tokens in files:
swap it in your json file to a token, ie. { "HideExperimentalFeature": #{HideExperimentalFeature}# }
In your release pipeline you set these variables:
Upvotes: 3