OctopusReleaseNumber Not Available

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

Hi Kori,

You are right, $OctopusReleaseNumber somehow got into the documentation without ever making it into the code. I’ll include a fix in the next release.

For now if you need to make it unique, you could use a combination of $OctopusPackageVersion + “.” + $OctopusTaskId - that will at least give you some way of relating the release to a task in Octopus. I’ve checked and OctopusTaskId is definitely available.

Sorry for the inconvenience!

Paul

No worries, I’ll use the package + task as the version for now. I was just more curious if it was just not something I should have been using. :slight_smile:

Apologies for all the bugs - I seem to be hitting (though hopefully giving you good feedback) them all. I hit another one this morning, did you want me to create a new ticket?

Apologies for all the bugs

Not at all, thank you for taking the time to report them! You’re helping to improve the product, and that’s really important to me (and what a beta program is for :)) so thanks!

Paul

:slight_smile: Thanks. I’ll keep an eye out for the next release.