Creating releases from TeamCity and "Latest" packages for multiple branches

We are using TeamCity to do our builds and using the “OctopusDeploy: Create release” to create our releases inside Octopus. For ease of explaining we have two releases 1.1 and 1.2. Each release contains two separate packages PkgA and PkgB. What I am having issues with is creating releases for 1.1 when I am building PkgA. I cannot figure out a way to create a release for 1.1 that where I can specify the exact version of PkgA (which I know) and the latest of 1.1 of PkgB (which I don’t know from TeamCity). If I don’t specify the version of PkgB I run into a problem now where I am getting the exact version of PkgA (1.1.10) and the latest of PkgB which is 1.2.X which obviously isn’t what I am looking for.

Any insight is much appreciated

Greetings! If I understand you correctly, you have a specific version range that you’d like to work with and the latest of Package B falls outside that range when creating a release, is this correct? If this is the case, you might want to consider the Channel Version Rules component of our Channels feature. Version Rules allow you to control which versions of packages are allowed for that specific channel. You could create a rule for Package B that states it has to be less than 1.2, Octopus will automatically select the latest package that falls below 1.2, does that make sense?

If that won’t work for you, and you are able to get the version number built for Package B, you could specify the --package= argument in the Additional command line arguments: section under Advanced for the Create Release task

image

Does this help?

Regards,

Shawn

I was able to determine this by using a simple Powershell script and setting a variable which I used to pass as the additional command line argument --package=SERVERVERSION:%SERVERVERSION%

GetServerVersion.ps1

$bearer_token = "TEAMCITY_TOKEN"
$headers = @{Authorization = "Bearer $bearer_token"}

# Construct the URL Request
$unencoded_branch_name = %teamcity.build.branch%
$branch_name = [uri]::EscapeDataString($unencoded_branch_name)
$build_name_id = "TEAMCITY_JOB_ID"
$id_url = "http://teamcity/app/rest/buildTypes/id:${build_name_id}/builds/branch:name:${branch_name}/id"

$id = Invoke-RestMethod -ContentType "$contentType" -Uri $id_url -Method GET -Headers $headers -UseBasicParsing

# Now that we have the ID of the latest build we want to get the SEMVER
$semver_url = "http://teamcity/app/rest/builds/id:${id}/resulting-properties/SEMVER"
$semver = Invoke-RestMethod -ContentType "$contentType" -Uri $semver_url -Method GET -Headers $headers -UseBasicParsing

$message = "##teamcity[setParameter name='SERVERVERSION' value='$semver']"
Write-Host $message

Excellent! Glad you were able to get it working :slight_smile:

Regards,

Shawn