Using Octopus.Client and getting multi-tenant versions

Hello

We are currently using Octopus to deploy in a multi tenant environment, and would like to use the Octopus.Client for C# to retrieve the current version that each tenant is running for a specific project.

Anyone got a suggestion on how we can get this information?
As a bonus question, does anyone know how to check if a release is still used?

Hi Nick,

The DashboardRespository is your friend here. Something like the following:

// Create repository
var repository = new OctopusRepository(new OctopusServerEndpoint("http://YourServerUrl", "API-YourApiKey"));

// Find the project, environment, and tenant
var project = repository.Projects.FindByName("Your Project Name");
var environment = repository.Environments.FindByName("You Environment Name");
var tenant = repository.Tenants.FindByName("Your Tenant Name");

// Get the dashboard
var dashboard = repository.Dashboards.GetDynamicDashboard(new[] {project.Id}, new[] {environment.Id});
var latestTenantDeploymentForEnvironment = dashboard.Items.Single(item => item.TenantId == tenant.Id);

// The version
var version = latestTenantDeploymentForEnvironment.ReleaseVersion;

Regarding checking if a release is still used, if you mean checking if a release is still currently deployed to any environment, then again the DashboardRepository can give you this. By tweaking the example above you can get the dashboard items for all environments, and iterate over them checking if any are still using the release version you are interested in.

I hope that helps. Please let me know if that doesn’t give you what you want, or if we can be of any assistance.

Regards,
Michael