Get currently deployed production release


We have just upgraded to v2.4 form 1.6 ( I know). We have been using the octopus API quite extensively from powersehell. One key feature we were using was the ability to get the currently deployed production release, so that we could decide upon what content needed to be included ( long story).

We were previously doing something very similar to this gist:

With the following function being the key bit:

function GetLatestDeployedRelease {

        $environments = Get($root.Links.Environments) 
        $deployments = Get($project.Links.RecentDeployments)

        foreach ($env in $environments | Sort-Object SortOrder -descending) {
            foreach ($deployment in $deployments) {
                if ([string]::Compare($env.Id, $deployment.EnvironmentId, $true) -eq 0) {
                    return Get($deployment.Links.Release)

        return $null;

I have had a play with the new API and it looks like it is not currently possible now. Can some one point me in the right direction ?




It’s great to hear you’ve taken the plunge. You’ll be glad to know this is possible in Octopus v2.4. One of the best things about Octopus is anything you can tell from the website you can discover via the API.

The best way to find the current Release in an environment for a project is via the Dashboard API.

The following PowerShell sample shows how to determine the ReleaseVersion given a project and an environment.

$environment = "Environments-1"
$project = "projects-1"

$queryString = "?environments=$environment&projects=$project"

$octopus_url = "http://localhost:88" # Url of the API

$url = "/api/dashboard/dynamic$queryString"

$octopus_apikey = "API-0000000000"

$result = Invoke-RestMethod -Uri "$octopus_url$url" -ContentType application/json -Headers @{"X-Octopus-ApiKey"="$octopus_apikey"} -Method Get -Verbose 

The result will contain a list of items for all the matching Deployments. So you can extract the ReleaseVersion like this:


For reference here is the entire respose:

Projects      : {@{Id=projects-1; Name=Project; Slug=project; ProjectGroupId=ProjectGroups-1; Links=}}
ProjectGroups : {@{Id=ProjectGroups-1; Name=All Projects; EnvironmentIds=System.Object[]; Links=}}
Environments  : {@{Id=Environments-1; Name=Environment; Links=}}
Items         : {@{Id=deployments-260; ProjectId=projects-1; EnvironmentId=Environments-1; ReleaseId=releases-132;
                DeploymentId=deployments-260; TaskId=ServerTasks-424; ReleaseVersion=3.2.19;
                Created=2014-05-29T01:10:20.715+00:00; QueueTime=2014-05-29T01:10:21.592+00:00;
                CompletedTime=2014-05-29T01:10:53.660+00:00; State=Success; HasPendingInterruptions=False;
                HasWarningsOrErrors=False; ErrorMessage=; Duration=32 seconds; Links=}}
Links         :



1 Like