From 10fa1fc1ddfe41e27aa793bd6aa9e25d4c2c3170 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 2 Apr 2019 11:56:48 -0700 Subject: [PATCH] Move artifacts to artifact staging directory before uploading (#9273) --- tools/ci.psm1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/ci.psm1 b/tools/ci.psm1 index e88844437..e40a0cf38 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -346,13 +346,26 @@ function Invoke-CIAfterTest $codeCoverageOutput = Split-Path -Parent (Get-PSOutput) $codeCoverageArtifacts = Compress-CoverageArtifacts -CodeCoverageOutput $codeCoverageOutput - Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts' - $codeCoverageArtifacts | ForEach-Object { - Push-Artifact -Path $_ -Name 'CodeCoverage' + $destBasePath = if ($env:TF_BUILD) { + $env:BUILD_ARTIFACTSTAGINGDIRECTORY + } else { + Join-Path (Get-Location).Path "out" } - New-TestPackage -Destination (Get-Location).Path - $testPackageFullName = Join-Path $pwd 'TestPackage.zip' + if (-not (Test-Path $destBasePath)) + { + $null = New-Item -ItemType Directory -Path $destBasePath + } + + Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts' + $codeCoverageArtifacts | ForEach-Object { + Copy-Item -Path $_ -Destination $destBasePath + $newPath = Join-Path $destBasePath (Split-Path $_ -Leaf) + Push-Artifact -Path $newPath -Name 'CodeCoverage' + } + + New-TestPackage -Destination $destBasePath + $testPackageFullName = Join-Path $destBasePath 'TestPackage.zip' Write-Verbose "Created TestPackage.zip" -Verbose Write-Host -ForegroundColor Green 'Upload test package' Push-Artifact $testPackageFullName -Name 'CodeCoverage'