Select Deployment targets by currently deployed version

When performing a manual deployment for a given release, I can pick specific tenants, and I can use the Tenant Tags to select groups of tenants.

For example, I find a fix a bug in my application.

The bug was introduced in version 1.3.004.
The fix was included in version 1.3.006.

It would be really helpful to select Tenants based on the version currently deployed to that tenant.
So I can only deploy to tenants with version 1.3.004 or greater.

I can pick individual tenants, but that can get cumbersome when you get into larger numbers of tenants.

Hi Phil,

Thank you for getting in touch, and great question! Unfortunately there’s no built-in functionality to select tenants based on current version - the closest thing I think is to filter the project’s overview page by a release version, which will show if all of the tenants have had that release deployed to it, but you’re right, that can easily become very cumbersome to keep referencing to add each tenant to a new deployment.

The best option would be to write an API script to automate this task. However, I don’t see any existing samples that do exactly this, but a few pieces to what I imagine would be required might give you a good starting point if you’re interested in going this route.

You could run something like the below script to query all tenants and get just those that are connected to this specific project and environment.

$projectId = "Projects-2428"
$environmentId = "Environments-1541"

$tenant = (Invoke-RestMethod -Method Get "$octopusURL/api/Spaces-202/tenants/all" -Headers $headers) | Where-Object {$_.ProjectEnvironments.PSObject.Properties.Name -eq $projectId && $_.ProjectEnvironments.PSObject.Properties.Value -eq $environmentId}


Then use the returned tenants to query the project to find the most recent release deployed to each in that environment. The following sample script would need tweaking to meet your requirements, as it queries all projects and returns the most recent deployed release for each environment.

I’m sorry I don’t have an end-to-end example, but hopefully that helps in some way! Let me know if you have any further questions or concerns.

Best regards,