Note that there are some explanatory texts on larger screens.

plurals
  1. POTeamcity change node in xml file
    text
    copied!<p>i need to change node (true or false because of configuration)in xml file on a remote computer, working in Teamcity, wrote the following function</p> <pre><code> function Set-layout($hiddenfunctionality) { $properties = Resolve-Path ".\vsphere\properties.ps1" . $properties #Read env.properties $configFilePath = Resolve-Path ".\environment\prod-env\env.properties" Write-Host $configFilePath $file = resolve-path("$configFilePath") [xml]$doc = Get-Content $file $node = $doc.SelectSingleNode("/project/property[@name='backend.server']") $backend_ip = $node.value $layoutRel = Resolve-Path ".\layout\layoutRel.ps1" #Remote-Copy $layoutRel "\\$backend_ip\install" Copy-Item $layoutRel "\\$backend_ip\install" $dom_user = [string]($domain_name+ "\" + $domain_username) $Connection = @{"server" = $backend_ip; "username" = $dom_user; "password" = $domain_password} $rem_command = 'powershell -ExecutionPolicy RemoteSigned . c:\Empower\install\layoutRel.ps1 $hiddenfunctionality' RemoteCommand $Connection $rem_command } </code></pre> <p>this function is working and it call the script which will change the value of the node "configuration/appSettings/add[@key='opentext.empower.site.enableHiddenFunctionality"</p> <pre><code> Param ($hiddenfunctionality) Write-Host "Updating C:\Program Files\Opentext\Empower\Web\Web.config" [System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument $file = resolve-path("C:\Program Files\Opentext\Empower\Web\web\Web.config") $xd.load($file) $xd.SelectNodes("configuration/appSettings/add[@key='opentext.empower.site.enableHiddenFunctionality']").Item(0).SetAttribute( 'value', $hiddenfunctionality) $xd.Save( $file) Write-Host "Done" </code></pre> <p>In my teamcity configs do the following string</p> <pre><code> powershell . %teamcity.build.checkoutDir%\Build\CI_2.0\vsphere\env-handler.ps1; Set-layout $true </code></pre> <p>all it works, but field value in my file is empty, but should be true or false( </p> <p>and i can't make a static true or false. it should be change because of some configurations in Teamcity</p> <p>Maybe i can take the name of build configuration from teamcity anf if cat_1 than run "true" if cat_2 than "false" but i don't know how to do it</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload