Skip to content

Commit

Permalink
LastDeploymentFailed behaviour fixed + version 2.x bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees Schollaart committed Nov 18, 2017
1 parent 0d36632 commit fff830e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions arm-outputs/arm-outputs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Write-Verbose "Entering script arm-outputs.ps1"

Write-Debug "ResourceGroupName= $resourceGroupName"

$lastResourceGroupDeployments = Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName | Sort-Object Timestamp -Descending
$lastResourceGroupDeployment = $lastResourceGroupDeployments | Select-Object -First 1

if ($whenLastDeploymentIsFailed -eq "latestSuccesful" ) {
$lastDeploymentStatus = $lastResourceGroupDeployment.ProvisioningState
if ($lastResourceGroupDeployment -and $lastDeploymentStatus -ne "Succeeded") {
Write-Debug "Last deployment of Resource Group '$resourceGroupName' did not succeed ('$lastDeploymentStatus'), ingoring this deployment and finding latest succesful deployment"
Write-Verbose "Last deployment of Resource Group '$resourceGroupName' did not succeed ('$lastDeploymentStatus'), ingoring this deployment and finding latest succesful deployment"
}
$lastResourceGroupDeployments = $lastResourceGroupDeployments | Where-Object {$_.ProvisioningState -eq "Succeeded"}
}
Expand All @@ -20,8 +21,7 @@ if (!$lastResourceGroupDeployment) {

$lastDeploymentStatus = $lastResourceGroupDeployment.ProvisioningState
if ($whenLastDeploymentIsFailed -eq "fail" -and $lastDeploymentStatus -ne "Succeeded") {
Write-Error "Last deployment of Resource Group '$resourceGroupName' did not succeed (status '$lastDeploymentStatus')"
return;
throw "Last deployment of Resource Group '$resourceGroupName' did not succeed (status '$lastDeploymentStatus')"
}

if (!$lastResourceGroupDeployment.Outputs) {
Expand Down
1 change: 1 addition & 0 deletions arm-outputs/run-vsts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ Initialize-Azure
$resourceGroupName = Get-VstsInput -Name resourceGroupName -Require
$prefix = Get-VstsInput -Name prefix
$outputNames = Get-VstsInput -Name outputNames
$whenLastDeploymentIsFailed = Get-VstsInput -Name whenLastDeploymentIsFailed

.\arm-outputs.ps1
6 changes: 3 additions & 3 deletions arm-outputs/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
],
"author": "Kees Schollaart",
"version": {
"Major": 1,
"Minor": 15,
"Patch": 0
"Major": 2,
"Minor": 0,
"Patch": 2
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "arm-outputs",
"name": "ARM Outputs",
"version": "1.1.2",
"version": "2.0.6",
"publisher": "keesschollaart",
"public": true,
"helpMarkDown": "[More Information](https://github.com/keesschollaart81/vsts-arm-outputs)",
Expand Down

0 comments on commit fff830e

Please sign in to comment.