Hey Paul,
I’m attempting to write a Deploy.ps1 script which updates the web.config with the release number which I was planning on using OctopusReleaseNumber over OctopusPackageVersion because I’ve been using the package version and adding .0 .1 to the end, like so:
Package Version = 2.0.100
Release Version, First Deploy = 2.0.100.0
Release Version, Second Deploy = 2.0.100.1
The problem is that I’m getting nothing back for the variable, like if I use the following:
Write-Host "Release version being deployed: " $OctopusReleaseNumber
My whole Deploy.ps1 script looks like the following:
Write-Host "Package Path: " $OctopusPackageDirectoryPath
# Find the web.config
$configName = (Get-ChildItem $OctopusPackageDirectoryPath\*.config -Name | Select-Object -First 1)
$configPath = (Join-Path $OctopusPackageDirectoryPath $configName)
Write-Host "Config Path:" $configPath
Write-Host "Date being deployed: " ([System.DateTime]::Now.ToString("MM/dd/yyyy h:mm:ss tt"))
Write-Host "Release version being deployed: " $OctopusReleaseNumber
Write-Host "Package version being deployed: " $OctopusPackageVersion
[xml]$xml = New-Object XML
$xml.Load($configPath)
foreach($n in $xml.selectnodes("/configuration/appSettings/add"))
{
switch($n.key)
{
"ApplicationDeploymentDate" { $n.value = ([System.DateTime]::Now.ToString("MM/dd/yyyy h:mm:ss tt")) }
"ApplicationVersion" { $n.value = $OctopusReleaseNumber }
}
}
$xml.Save($configPath)
Is that variable $OctopusReleaseNumber something I can use from the deploy script? I assumed so, since I can seem to use OctopusPackageVersion.
Thanks,
Kori