Deploy/Promote an existing release in a specific environment to another specific environment

I would like to deploy an existing release from one selected environment to another environment.
I deploy the release in Beta to prod Approval, only after this release approved I need to deploy that release from
Beta -> Demo
ProdApproval -> Prod

Based on my research, I know that I should provide Project id, deployment id, environment id and release id.
But how can I get the release-id from Beta abd ProdApproval environements only to promote them to Demo and Prod respectively.

Can someone suggest me a solution how to achieve this.


The solution is to use Channels, with channels you can have different lifecycles per channel.
Have a read of the documentation page I linked before, it should explain everything.
And if you still unclear on anything let us know :slight_smile:


Thanks for your reply John, can you please elaborate the idea little bit more as I am new to Octopus Deploy and just started using Octopus Rest API.

We are planning to promote releases for multiple projects (4 projects) at a time.


From what I gather from your initial question it seems you have different branch strategies, eg you may want to release your software to only a subset of people (the Beta group) and then you also have your Production branch.
With Channels, you can build your pipeline in such a way that you model exactly these distinct groups.

Can you expand more on your release pipeline, so I understand it a bit more?

Also, we have this documentation page that goes into more detail, hopefully, this doc will clarify a few more things?


Hi John,

I referred your github page for this task, and used CreateReleaseAndDeployment.ps1 code.

I provided the source and destination environments to promote a release from source to destination environments respectively.

But I would like to check if that version already exists or not before I deploy. is there any way to check this?

Hi Amulya,

You can check whether a release has been deployed to an environment by making the following API call. The EnvironmentId property on the Deployment resource is what you are looking for.

Please, let me know if this doesn’t solve your problem.



1 Like

Thanks Pawel, it worked.

For my next step, I need to make it scheduled deployment, I’m planning to do it using Windows Task Scheduler.

Is it possible using Rest API.

Scheduled deploys via API I found this issue opened few years ago but it was closed.

This is my code to promote deployments from Mirror to Beta.

$apiKey = “API-XXX”
$Header = @{ “X-Octopus-ApiKey” = $apiKey }
$OctopusURL = “ URL
$ProjectsSlugs = @(“test”);
$DestEnvironmentName = “Beta” #Destination Env
$SourceEnvironmentName = “Mirror” #Source Env

foreach($ProjectSlugName in $ProjectsSlugs){
echo $ProjectSlugName

$Environments = Invoke-WebRequest -Uri "" -UseBasicParsing  -Headers $Header | ConvertFrom-Json
$Project = Invoke-WebRequest -Uri "$ProjectSlugName" -UseBasicParsing -Headers $Header| ConvertFrom-Json

$DestEnvironment = $Environments | ?{$ -eq $DestEnvironmentName}
$SourceEnvironment = $Environments | ?{$ -eq $SourceEnvironmentName}

$ProjectId = $Project.Id
$DestEnvId = $DestEnvironment.Id
$SourceEnvId = $SourceEnvironment.Id

$DeploymentData = Invoke-WebRequest -Uri "$SourceEnvId&projects=$ProjectId&taskState=Success" -UseBasicParsing -Headers $Header | ConvertFrom-Json
$ReleaseId = $DeploymentData.Items.ReleaseId | select -uniq
echo $Project.Name $ProjectId 
echo "Destination: "$DestEnvironment.Name $DestEnvId 
echo "Source: "$SourceEnvironment.Name $SourceEnvId 
echo $ReleaseId

if (-not ([string]::IsNullOrEmpty($ReleaseId)))
    echo "Release exists in source environment"
    $checkRelease = Invoke-WebRequest -Uri "$ReleaseId/deployments" -UseBasicParsing -Headers $Header | ConvertFrom-Json
    $checkReleaseExists = $checkRelease.Items.EnvironmentId | select -uniq

        echo "Error: Release already exists in" $DestEnvironment.Name
        echo "Create a release; Release doesn't exists in "$DestEnvironment.Name
        $DeploymentBody = @{ 
                ReleaseID = $ReleaseId
                EnvironmentID = $DestEnvId 
              } | ConvertTo-Json
        $ReleaseProject = Invoke-WebRequest -Uri -UseBasicParsing -Method Post -Headers $Header -Body $DeploymentBody
    echo "Release doesn't exists in source environment"


Hi Amulya,

The issue was closed because we implemented the feature. Have a look at deployAt parameter in both DeployRelease and CreateRelease commands.

Let me know you go.



Thanks Pawel,
It worked fine, promote-release does the exact job for me.

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