Octopus.Script exported 2015-08-03 by pitrew belongs to ‘XML’ category.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
XML file path
path
null
XPath
xmlPath
XPath element with namespace //b
Key
key
Key to change
Value
value
New value
NS key
nsKey = B
Namespace key
NS Value
nsValue
Namespace value
Script body
Steps based on this template will execute the following PowerShell script.
[xml]$xml = Get-Content $path
$ns = new-object Xml.XmlNamespaceManager $xml.NameTable
$ns.AddNamespace($nsKey, $nsValue)
$xml.SelectNodes($xmlPath, $ns) | % {
if ($_.key -eq $key)
{
$_.value = $value
}
}
$xml.Save($path)
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "170a9b93-96f2-470b-81ca-e0ff53fa7c3d",
"Name": "XML update",
"Description": null,
"Version": 0,
"ExportedAt": "2015-08-03T13:50:55.041+00:00",
"ActionType": "Octopus.Script",
"Author": "pitrew",
"Parameters": [
{
"Name": "path",
"Label": "XML file path",
"HelpText": null,
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "xmlPath",
"Label": "XPath",
"HelpText": "XPath element with namespace //b:setting",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "key",
"Label": "Key",
"HelpText": "Key to change",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "value",
"Label": "Value",
"HelpText": "New value",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "nsKey",
"Label": "NS key",
"HelpText": "Namespace key",
"DefaultValue": "B",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "nsValue",
"Label": "NS Value",
"HelpText": "Namespace value",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptBody": "[xml]$xml = Get-Content $path \n$ns = new-object Xml.XmlNamespaceManager $xml.NameTable\n$ns.AddNamespace($nsKey, $nsValue)\n\n$xml.SelectNodes($xmlPath, $ns) | % {\n\tif ($_.key -eq $key)\n\t{\n\t\t$_.value = $value\n\t}\n}\n\n$xml.Save($path)",
"Octopus.Action.Script.Syntax": "PowerShell"
},
"Category": "XML",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/xml-attribute-update.json",
"Website": "/step-templates/170a9b93-96f2-470b-81ca-e0ff53fa7c3d",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACOlJREFUeNrsnc1TE2cYwNVhhnAinDb0QAIHsTBDsM4AVSvUj2qtDE6njh60emhr/512pnetPejQ6ehgrYxfBGurzlDBGZF4wMQDSU4kNzjRR2Ip7ru7+XoT8m5+v+MGdpN3f3me5/3abF9bW9sGoJsdNAEgFiAWIBYAYgFiAWIBIBYgFiAWAGIBYgFiASAWIBYgFgBiAWIBYgEgFiAWNBJN9fzmstlcIpnMZrONcCcCgUAkHA6FLMSqIisrK9dvTMTjrxrtix4Od5w5fUokM/2DbK/PfYWXLl9JJt80ZhJpbm6+cP6c6aGrHmus2bnnDWuVsLq6Kt+rdDqDWJpJJJINXvn6wK16FKtBqnV/u8VwA24hFm4hFjS4W4iFW1WhybhWjkb7gsFWH+gSiz0s1S2DxrfME6s/2heJhBtNLOPcIhWSExELzHELsXALscActxALtxALzHELsXALscActxALtxALzHELsXALscActxALtxALzHELsXALscActxALtxALzHELsXALscActxALtxALzHELsXALscActxALtxALzHELsXArg1hgjFuIhVtv3VpZWUEs0O/W1WvjiAX6SSbf6E2IiAXv0PuwasSCd6QzRCxfYFmWjz8dYm0ZQ0MDiAX66Y/2RaN9iAX6OTk2OjY2Gg53+O+jNXF3t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QQOjd1NdPYrlyw2cBogVCvldrO5uHlZTY8LhjmCw1ediySc8duwz3KoZlmWdOX1K7zl1PjVZL9lsbio2nUgkc7kc9756gSoSCQ8NDmjf8l+/YgG9QgDEAsQCxAJALEAsQCwAxALEAsQCQCxALEAsAMQCxALEAkAsQCxALEAsAMQCU/hXgAEAvqSVJBhJrL4AAAAASUVORK5CYII=",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Monday, August 3, 2015