diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index 0f21207464..69ea089d6c 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -15,6 +15,11 @@ jobs: displayName: 'Initialize Environment' inputs: filePath: 'scripts/azure-pipelines/windows/initialize-environment.ps1' + - task: PowerShell@2 + displayName: 'Report on Disk Space' + condition: always() + inputs: + filePath: 'scripts/azure-pipelines/windows/disk-space.ps1' # Note: D: is the Azure machines' temporary disk. - task: CmdLine@2 displayName: 'Build vcpkg' @@ -48,6 +53,11 @@ jobs: inputs: testResultsFiles: '$(System.ArtifactsDirectory)/xml-results/${{ parameters.triplet }}.xml' condition: always() + - task: PowerShell@2 + displayName: 'Report on Disk Space After Build' + condition: always() + inputs: + filePath: 'scripts/azure-pipelines/windows/disk-space.ps1' - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: ${{ parameters.triplet }} port build failure logs' inputs: diff --git a/scripts/azure-pipelines/windows/disk-space.ps1 b/scripts/azure-pipelines/windows/disk-space.ps1 new file mode 100644 index 0000000000..8680d77015 --- /dev/null +++ b/scripts/azure-pipelines/windows/disk-space.ps1 @@ -0,0 +1,35 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: MIT +# + +<# +.SYNOPSIS +Prints total and free disk space for each disk on the system +#> + +Function Format-Size { + [CmdletBinding()] + Param([long]$Size) + + if ($Size -lt 1024) { + $Size = [int]$Size + return "$Size B" + } + + $Size = $Size / 1024 + if ($Size -lt 1024) { + $Size = [int]$Size + return "$Size KiB" + } + + $Size = $Size / 1024 + if ($Size -lt 1024) { + $Size = [int]$Size + return "$Size MiB" + } + + $Size = [int]($Size / 1024) + return "$Size GiB" +} + +Get-CimInstance -ClassName Win32_LogicalDisk | Format-Table -Property @{Label="Disk"; Expression={ $_.DeviceID }},@{Label="Label"; Expression={ $_.VolumeName }},@{Label="Size"; Expression={ Format-Size($_.Size) }},@{Label="Free Space"; Expression={ Format-Size($_.FreeSpace) }}