Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions eng/common/pipelines/templates/steps/publish-blobs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
parameters:
FolderForUpload: ''
TargetLanguage: ''
BlobName: ''
ScriptPath: ''
BlobName: '' # To be removed once all usages are removed in the languages
BlobAccountName: 'https://azuresdkdocs.blob.core.windows.net'
ScriptPath: 'eng/common/scripts/copy-docs-to-blobstorage.ps1'
ArtifactLocation: ''
RepoId: $(Build.Repository.Name)

steps:
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
- pwsh: |
if (!(Test-Path '$(Build.BinariesDirectory)/azcopy/azcopy_windows_amd64_*/azcopy.exe')) {
Invoke-WebRequest -MaximumRetryCount 10 -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile "azcopy.zip" | Wait-Process;
Expand-Archive -Path "azcopy.zip" -DestinationPath "$(Build.BinariesDirectory)/azcopy/" -Force
}
workingDirectory: $(Build.BinariesDirectory)
displayName: Download and Extract azcopy Zip

- task: AzurePowerShell@5
displayName: 'Copy Docs to Blob Storage'
Expand All @@ -24,9 +18,8 @@ steps:
ScriptType: 'FilePath'
ScriptPath: ${{ parameters.ScriptPath }}
ScriptArguments: >
-AzCopy $(Resolve-Path "$(Build.BinariesDirectory)/azcopy/azcopy_windows_amd64_*/azcopy.exe")[0]
-DocLocation "${{ parameters.FolderForUpload }}"
-BlobName "${{ parameters.BlobName }}"
-BlobAccountName "${{ parameters.BlobAccountName }}"
-PublicArtifactLocation "${{ parameters.ArtifactLocation }}"
-RepoReplaceRegex "(https://github.com/${{ parameters.RepoId }}/(?:blob|tree)/)$(DefaultBranch)"
azurePowerShellVersion: latestVersion
Expand Down
20 changes: 9 additions & 11 deletions eng/common/scripts/copy-docs-to-blobstorage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# powershell core is a requirement for successful execution.
[CmdletBinding()]
param (
$AzCopy,
$DocLocation,
$BlobName,
$BlobAccountName = "https://azuresdkdocs.blob.core.windows.net",
$ExitOnError=1,
$UploadLatest=1,
$PublicArtifactLocation = "",
Expand Down Expand Up @@ -117,7 +116,7 @@ function Get-Existing-Versions
Param (
[Parameter(Mandatory=$true)] [String]$PkgName
)
$versionUri = "$($BlobName)/`$web/$($Language)/$($PkgName)/versioning/versions"
$versionUri = "${BlobAccountName}/`$web/$($Language)/$($PkgName)/versioning/versions"
LogDebug "Heading to $versionUri to retrieve known versions"

try {
Expand Down Expand Up @@ -175,9 +174,9 @@ function Update-Existing-Versions
$sortedVersionObj.LatestGAPackage | Out-File -File "$($DocLocation)/latest-ga" -Force -NoNewLine
$sortedVersionObj.LatestPreviewPackage | Out-File -File "$($DocLocation)/latest-preview" -Force -NoNewLine

& $($AzCopy) cp "$($DocLocation)/versions" "$($DocDest)/$($PkgName)/versioning/versions" --cache-control "max-age=300, must-revalidate"
& $($AzCopy) cp "$($DocLocation)/latest-preview" "$($DocDest)/$($PkgName)/versioning/latest-preview" --cache-control "max-age=300, must-revalidate"
& $($AzCopy) cp "$($DocLocation)/latest-ga" "$($DocDest)/$($PkgName)/versioning/latest-ga" --cache-control "max-age=300, must-revalidate"
azcopy cp "$($DocLocation)/versions" "$($DocDest)/$($PkgName)/versioning/versions" --cache-control "max-age=300, must-revalidate"
azcopy cp "$($DocLocation)/latest-preview" "$($DocDest)/$($PkgName)/versioning/latest-preview" --cache-control "max-age=300, must-revalidate"
azcopy cp "$($DocLocation)/latest-ga" "$($DocDest)/$($PkgName)/versioning/latest-ga" --cache-control "max-age=300, must-revalidate"
return $sortedVersionObj
}

Expand All @@ -189,8 +188,7 @@ function Upload-Blobs
[Parameter(Mandatory=$true)] [String]$DocVersion,
[Parameter(Mandatory=$false)] [String]$ReleaseTag
)
#eg : $BlobName = "https://azuresdkdocs.blob.core.windows.net"
$DocDest = "$($BlobName)/`$web/$($Language)"
$DocDest = "${BlobAccountName}/`$web/$($Language)"

LogDebug "DocDest $($DocDest)"
LogDebug "PkgName $($PkgName)"
Expand All @@ -215,7 +213,7 @@ function Upload-Blobs
}

LogDebug "Uploading $($PkgName)/$($DocVersion) to $($DocDest)..."
& $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)" --recursive=true --cache-control "max-age=300, must-revalidate"
azcopy cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/$($DocVersion)" --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)
Expand All @@ -228,7 +226,7 @@ function Upload-Blobs
if ($UploadLatest -and ($latestVersion -eq $DocVersion))
{
LogDebug "Uploading $($PkgName) to latest folder in $($DocDest)..."
& $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest" --recursive=true --cache-control "max-age=300, must-revalidate"
azcopy cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest" --recursive=true --cache-control "max-age=300, must-revalidate"
}
}

Expand All @@ -248,4 +246,4 @@ 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 $_; }
}
}