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

Backport #21441
This commit is contained in:
Patrick Meinecke
2024-04-05 20:14:39 +00:00
parent 89c9bb64ef
commit cf51c564de
+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
}