Skip to content

Instantly share code, notes, and snippets.

@IvanLieckens
Created June 25, 2021 06:34
Show Gist options
  • Save IvanLieckens/0a755ebcdf55e13bafa540e572957d2f to your computer and use it in GitHub Desktop.
Save IvanLieckens/0a755ebcdf55e13bafa540e572957d2f to your computer and use it in GitHub Desktop.
Custom Release Pipeline Steps
Import-Module .\Unicorn.psm1
function Wait-UnicornOnline
{
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$Uri,
[int]$MaxAttempts = 10
)
[int]$attempt = 1
[int]$resultCode = 0
while(($resultCode -ne 418) -and ($attempt -le $MaxAttempts))
{
try
{
Invoke-WebRequest -Uri $Uri
}
catch
{
$resultCode = [int]$_.Exception.Response.StatusCode
if ($resultCode -ne 418) {
Write-Host "[$attempt] Received status code $resultCode"
} else {
Write-Host "[$attempt] Unicorn is online and waiting for login"
}
$attempt++
if($attempt -eq $MaxAttempts)
{
throw "Max attempts reached but Sitecore is not online yet."
}
Start-Sleep -Seconds 10
}
}
}
Write-Host "Waiting for Unicorn to come online..."
Wait-UnicornOnline -Uri "$(Unicorn.Url)"
Sync-Unicorn -ControlPanelUrl "$(Unicorn.Url)" -SharedSecret "$(Unicorn.Secret)" -StreamLogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment