Bruce Foust
My feedback
-
3 votes
Bruce Foust supported this idea ·
-
22 votes
Bruce Foust supported this idea ·
-
8 votes
Bruce Foust supported this idea ·
-
1 vote
Bruce Foust shared this idea ·
I also had a need to stagger server deployments. I had to add a powershell wait step with the following code. (I don't remember where I pulled the example to give credit for the script.)
$seconds is the only parameter passed into the step for the initial wait.
if (($OctopusParameters['Octopus.Machine.Name'] -eq "SERVER3") -or ($OctopusParameters['Octopus.Machine.Name'] -eq "SERVER1T"))
{
[int]$Wait = [convert]::ToInt32($Seconds, 10) + 30
}
elseif ($OctopusParameters['Octopus.Machine.Name'] -eq "SERVER4")
{
[int]$Wait = [convert]::ToInt32($Seconds, 10) + 60
}
elseif ($OctopusParameters['Octopus.Machine.Name'] -eq "SERVER6")
{
[int]$Wait = [convert]::ToInt32($Seconds, 10) + 90
}
else
{
[int]$Wait = [convert]::ToInt32($Seconds, 10)
}
Write-Host "Waiting for $Wait Seconds."
$Increment = 4
$retries = $Wait / $Increment
$counter = 1
# Wait
if ($Wait -gt 0)
{
for($i=$Increment; $i -gt 0; $i--)
{
if ($Wait%$Increment -ne 0)
{
$tmp = "{0:N2}" -f ($retries * $i)
}
else
{
$tmp = $retries * $i
}
Write-Host "Time Remaining: $tmp seconds"
Start-Sleep $retries
}
}