Merged PR 30665: [release/v7.2.19] Verify environment variable for OneBranch before we try to copy (#21441)

Verify environment variable for OneBranch before we try to copy (#21441)
This commit is contained in:
Dongbo Wang
2024-04-05 20:15:17 +00:00
parent f386a91d17
commit d2f249d776
+10 -3
View File
@@ -48,13 +48,20 @@ function New-BuildInfoJson {
Write-Verbose -Message "$vstsCommandString" -Verbose
Write-Host -Object "##$vstsCommandString"
# Upload for ADO pipelines
Write-Host "##vso[artifact.upload containerfolder=BuildInfoJson;artifactname=BuildInfoJson]$resolvedPath"
# Copy to location where OneBranch Pipelines uploads from
# if the environment variable does not exist, we are not in OneBranch. So just return.
if (-not $env:ob_outputDirectory) {
return
}
if (-not (Test-Path $env:ob_outputDirectory)) {
$null = New-Item -Path $env:ob_outputDirectory -ItemType Directory -Force -Verbose
}
# Upload for ADO pipelines
Write-Host "##vso[artifact.upload containerfolder=BuildInfoJson;artifactname=BuildInfoJson]$resolvedPath"
# Copy to location where OneBranch Pipelines uploads from
Copy-Item $resolvedPath -Destination $env:ob_outputDirectory -Force -Verbose
}