Detecting a Project Promotion from Octopus Client

(Mark Bradley) #1

Hi,

I’m programtically orchestracting deployments via the Octopus Client.dll and powershell. So far creating releases is working great, however, I need a way to detect if the current release is being promoted from the UI, and account for that programmatically . Is there a straightforward way to check for this via the Octopus Client and powershell?

(Adam Close) #3

Hey Mark,

Thanks for reaching out!

So, I’ve created a script that filters all items on the dashboard by project, release, and environments. This will return me a dashboard item for a particular release for a specific project and environment. I’m then checking whether that the release is currently created/active and if the deployment was completed or is still active.

$projectId = $repository.Projects.FindByName(“PROJECT NAME”)
$environment = $repository.Environments.FindByName(“ENVIRONMENT NAME”)
$releaseVersion = “RELEASE VERSION”

$dashboardItems = $repository.Dashboards.GetDashboard().Items

$release = $dashboardItems | Where-Object{$.ProjectId -eq $projectId.Id -and $.ReleaseVersion -eq
$releaseVersion -and $_.EnvironmentId -eq $environment.Id }

if ($release.IsCurrent -eq $true -and $release.IsCompleted -eq $false)
{
Write-Host “There is a deployment in process for this project, release, and environment.”
}

I hope this helps but reach out again if you need further assistance :slight_smile:

Thanks