Skip to content

Commit

Permalink
Improve diagnostics for copy-docs-to-blobstorage script (#5412)
Browse files Browse the repository at this point in the history
  • Loading branch information
weshaggard authored Feb 13, 2023
1 parent fde004d commit 30dd44f
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions eng/common/scripts/copy-docs-to-blobstorage.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Note, due to how `Expand-Archive` is leveraged in this script,
# powershell core is a requirement for successful execution.
[CmdletBinding()]
param (
$AzCopy,
$DocLocation,
Expand Down Expand Up @@ -199,32 +200,32 @@ function Upload-Blobs
LogDebug "Final Dest $($DocDest)/$($PkgName)/$($DocVersion)"
LogDebug "Release Tag $($ReleaseTag)"

# Use the step to replace default branch link to release tag link
# Use the step to replace default branch link to release tag link
if ($ReleaseTag) {
foreach ($htmlFile in (Get-ChildItem $DocDir -include *.html -r))
foreach ($htmlFile in (Get-ChildItem $DocDir -include *.html -r))
{
$fileContent = Get-Content -Path $htmlFile -Raw
$updatedFileContent = $fileContent -replace $RepoReplaceRegex, "`${1}$ReleaseTag"
if ($updatedFileContent -ne $fileContent) {
Set-Content -Path $htmlFile -Value $updatedFileContent -NoNewLine
}
}
}
}
else {
LogWarning "Not able to do the default branch link replacement, since no release tag found for the release. Please manually check."
}
}

LogDebug "Uploading $($PkgName)/$($DocVersion) to $($DocDest)..."
& $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)$($SASKey)" --recursive=true --cache-control "max-age=300, must-revalidate"

LogDebug "Handling versioning files under $($DocDest)/$($PkgName)/versioning/"
$versionsObj = (Update-Existing-Versions -PkgName $PkgName -PkgVersion $DocVersion -DocDest $DocDest)
$latestVersion = $versionsObj.LatestGAPackage
$latestVersion = $versionsObj.LatestGAPackage
if (!$latestVersion) {
$latestVersion = $versionsObj.LatestPreviewPackage
$latestVersion = $versionsObj.LatestPreviewPackage
}
LogDebug "Fetching the latest version $latestVersion"

if ($UploadLatest -and ($latestVersion -eq $DocVersion))
{
LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..."
Expand All @@ -243,3 +244,9 @@ else
See https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/common_engsys.md#code-structure"
}

# If we hit a failure then dump out the azcopy logs to help with debugging
if ($LASTEXITCODE)
{
Write-Host "Copying failed with error code [$LASTEXITCODE]. Dumping the logs to help diagnose."
Get-ChildItem $env:UserProfile\.azcopy -Filter *.log | ForEach-Object { "LOG: " + $_; Get-Content $_; }
}

0 comments on commit 30dd44f

Please sign in to comment.