Update a specific json object's property with a specified value. You can target nested json objects, and even objects that belong to an array. Available on the Visual Studio Marketplace
Note: SetJsonProperty has been designed to work with Azure DevOps pipelines running specifically on Windows machines.
This couldn't be easier, simply specify the property path as you would in javascript.
{
"MyProperty":"TheValueToUpdate"
}
To target the above property MyProperty
and update it's value, you would set MyProperty
as your Property Path.
{
"Property1": "Value1",
"MyNestedObject": {
"MyProperty": "TheValueToUpdate"
}
}
In the above example, you would target MyProperty
the same as you would in javascript MyNestedObject.MyProperty
You don't have to stop there, you can access properties on objects nested much deeper than that.
{
"Property1": "Value1",
"MyNestedObject": {
"NestedProperty": [
{
"Key": "Value1"
},
{
"Key": "Value2"
},
{
"Key": "Value3"
}
]
}
}
In the above example, let's say you wanted to target the second instance of Key
and update it's value. Again, as with javascript, you would specify the property path and an array index like so MyNestedObject.NestedProperty[1].Key
There are a number of ways you can provide a value with which to update your property. You can simply enter a value into the "Property Value" field e.g. MyNewValue
. You can specify an environment variable too, for example your build number $(Build.BuildNumber)
This means you can also access an environment variable that has been set by another task, previously in your pipeline.
Check out the wiki for more information.
- Minimum agent version: 2.123.0
- 1.0.5
Update character escape regex to only check for hex values - 1.0.4
README Update - 1.0.3
Fixed character escaping issues when parsing Json.
Find more about me at ThatBlokeCalledJay.com