A Repeat Deployment Number

When I push the same release to the same environment multiple times, my deployments are labelled as “Deploy to QA #2”, “Deploy to QA #3” and so on. We would like to be able to surface this sequence number (#2, #3, etc.) in the PowerShell script via a system variable. Is it possible at all?

Hi there,

Thanks for reaching out! We don’t story that number anywhere, but you could get it with powershell this way:

$DeploymentName = $OctopusParameters['Octopus.Deployment.Name']

If($DeploymentName.Contains('#')){

    $DeploymentNumber = $DeploymentName.Split('#')[-1].Replace(")","")
}

else{
    $DeploymentNumber = 1
}

write-output "The deployment number is: $deploymentNumber"

Hope that helps!
Dalmiro