Release.PreviousForEnvironment.Number for multi tenant

I have a multi tentant project and I want to know the previously released number for that project (and for the current environment) but I am getting a random(?) number. I am using:


But it returns not the previous number for that tenant (in my case: it gives the number of the tenant above it, but that seems a coincidence).

Is this a bug? Is this not supported? In fact I think I am looking for:


Hi Gerjan,

Thanks for getting in touch! Getting a random number from this Release.PreviousForEnvironment.Number sounds very strange. It should be pulling the latest release number deployed to that environment (and this is regardless of the tenant). If you don’t see any reason for the value you’re getting back, could you provide some additional information to help me dig in further? A verbose deployment log with debugging variables enabled will be the most helpful, and you can reference the doc page below.

Unfortunately we don’t have a specific system variable for the previous release version for environment and tenant combination. I think this sounds like a good idea for a new variable, and I’ll bring it up with my team. For the time being, I was able to get the last successfully deployed release to the environment/tenant combination by going directly via the API in a script step which I’ll paste below.

$OctopusURL = "" #Octopus URL
$OctopusAPIKey = "" #Octopus API Key

$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$ProjectID = $OctopusParameters['Octopus.Project.ID']
$EnvironmentID = $OctopusParameters['Octopus.Environment.ID']
$TenantID = $OctopusParameters['Octopus.Deployment.Tenant.Id']

$ProjectDashboardReleases = (Invoke-WebRequest $OctopusURL/api/progression/$ProjectID -Method Get -Headers $header -UseBasicParsing).content | ConvertFrom-Json

$LastSuccessfullRelease = $ProjectDashboardReleases.Releases.Deployments.$EnvironmentId | ?{$_.state -eq "Success"} | ?{$_.TenantId -eq "$TenantID"} | select -First 1


Does this help get the information you’re after? Please let me know how you go or if you have any further questions going forward. :slight_smile:

Best regards,


Awesome, your script is working great!

But yes, I think its still a great addition: Release.PreviousForEnvironmentForTenant.Number

Hi @GerjanOnline,

That sounds great! Thanks for letting me know. I agree this would be a good variable to add, though I’m not sure how highly it could be prioritized. It might be worth suggesting this on our UserVoice site in order to gauge community support behind it. :slight_smile:

Don’t hesitate to reach out if you have any further questions or concerns moving forward!

Best regards,


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.