Skip to content

Instantly share code, notes, and snippets.

@ErikHen
Last active July 16, 2020 08:43
Show Gist options
  • Save ErikHen/269e3f1095eb0ede6664871470307cf7 to your computer and use it in GitHub Desktop.
Save ErikHen/269e3f1095eb0ede6664871470307cf7 to your computer and use it in GitHub Desktop.
# DXC-S deploy from source environment to target environment. Step one that deploys to a slot on target.
# Install the EpiCloud module
if (-not (Get-Module -Name EpiCloud -ListAvailable)) {
Install-Module EpiCloud -Scope CurrentUser -Force
Write-Output "Installed EpiCloud module"
}
Connect-EpiCloud -ClientKey $OctopusParameters["DXC-S API Key"] -ClientSecret $OctopusParameters["DXC-S API Secret"]
# Check if there is an ongoing deployment
$deployments = Get-EpiDeployment -ProjectId $OctopusParameters["DXC-S Project Id"]
$ongoingdeployid = 0
Foreach ($deployment in $deployments) {
if ($deployment.parameters.targetEnvironment -eq $OctopusParameters["DXC-S Target environment"] ) {
if ($deployment.status -eq 'AwaitingVerification' -Or $deployment.status -eq 'InProgress' ) {
$ongoingdeployid = $deployment.id
Write-Host $deployment
break
}
}
}
if ($ongoingdeployid -eq 0) {
$deployment = Start-EpiDeployment -ProjectId $OctopusParameters["DXC-S Project Id"] -SourceEnvironment $OctopusParameters["DXC-S Source environment"] -TargetEnvironment $OctopusParameters["DXC-S Target environment"] -SourceApp cms -Wait
}
else {
Write-Warning "There already is an ongoing deployment ($ongoingdeployid), skipping this step."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment