In the config file ( json ) of my program, there is a field whose value type is a list of objects. My question is, how can I edit it in the pipeline?
In the following case I want to change "DownstreamScheme" from "https" to "http".
How should I define the variable so that the program can do this?
{
"Routes": [
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44354
}
],
"UpstreamPathTemplate": "/authentication/{everything}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
//,
//"AuthenticationOptions": {
// "AuthenticationProviderKey": "Bearer",
// "AllowedScopes": []
//}
//,"RateLimitOptions": {
// "ClientWhitelist": [],
// "EnableRateLimiting": true,
// "Period": "5s",
// "PeriodTimespan": 1,
// "Limit": 1
//}
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44333
}
],
"UpstreamPathTemplate": "/company/{everything}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44372
}
],
"UpstreamPathTemplate": "/navigator/{everything}",
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:44395"
}
}
How should I define the variable so that the program can do this?
You can define the Pipeline variable: Routes.0.DownstreamScheme : http
For example:

Then you can use File Transform task to update the value to http.
steps:
- task: FileTransform@1
displayName: 'File Transform: '
inputs:
folderPath: '$(build.sourcesdirectory)'
fileType: json
targetFiles: appsettings.json
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