Skip to content

Commit eb5546d

Browse files
authored
Fix download issues in pipelines (#15901)
* Fix download issues in pipelines * Fix pipeline YAML
1 parent 6f1ea33 commit eb5546d

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

.ado/jobs/desktop-single.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,29 @@ steps:
2727
displayName: Install IIS
2828
2929
- pwsh: |
30-
Invoke-WebRequest `
30+
function Invoke-WebRequestWithRetry($Uri, $OutFile, $MaxRetries = 3) {
31+
for ($i = 1; $i -le $MaxRetries; $i++) {
32+
try {
33+
Write-Host "Downloading $OutFile (attempt $i of $MaxRetries)"
34+
Invoke-WebRequest -Uri $Uri -OutFile $OutFile
35+
return
36+
} catch {
37+
Write-Host "Attempt $i failed: $_"
38+
if ($i -eq $MaxRetries) { throw }
39+
Start-Sleep -Seconds (5 * $i)
40+
}
41+
}
42+
}
43+
44+
Invoke-WebRequestWithRetry `
3145
-Uri 'https://download.visualstudio.microsoft.com/download/pr/20598243-c38f-4538-b2aa-af33bc232f80/ea9b2ca232f59a6fdc84b7a31da88464/dotnet-hosting-8.0.3-win.exe' `
3246
-OutFile dotnet-hosting-8.0.3-win.exe
3347
3448
Write-Host 'Installing .NET hosting bundle'
3549
Start-Process -Wait -FilePath .\dotnet-hosting-8.0.3-win.exe -ArgumentList '/INSTALL', '/QUIET', '/NORESTART'
3650
Write-Host 'Installed .NET hosting bundle'
3751
38-
Invoke-WebRequest `
52+
Invoke-WebRequestWithRetry `
3953
-Uri 'https://download.visualstudio.microsoft.com/download/pr/f2ec926e-0d98-4a8b-8c70-722ccc2ca0e5/b59941b0c60f16421679baafdb7e9338/dotnet-sdk-7.0.407-win-x64.exe' `
4054
-OutFile dotnet-sdk-7.0.407-win-x64.exe
4155

.ado/jobs/linting.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,29 @@ jobs:
1616
variables: [template: ../variables/windows.yml]
1717
pool: ${{ parameters.AgentPool.Medium }}
1818
steps:
19-
- template: ../templates/checkout-shallow.yml
19+
- ${{ if eq(parameters.buildEnvironment, 'Continuous') }}:
20+
- template: ../templates/checkout-shallow.yml
21+
parameters:
22+
persistCredentials: true
23+
24+
# Extract the GitHub OAuth token that ADO uses to clone the repo.
25+
# Any authenticated token raises the GitHub API rate limit from 60 to
26+
# 5,000 req/hr, which prevents validate-overrides from being throttled.
27+
- pwsh: |
28+
$headerLine = git config --get-regexp "http.*\.extraheader" 2>$null | Select-Object -First 1
29+
if (-not $headerLine) {
30+
Write-Host "##vso[task.logissue type=warning]No HTTP extraheader found — validate-overrides will run without GitHub auth"
31+
exit 0
32+
}
33+
$encoded = ($headerLine.Split(' ')[-1]).Trim()
34+
$decoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($encoded))
35+
$token = $decoded.Split(':')[-1]
36+
Write-Host "Extracted GitHub OAuth token (length=$($token.Length))"
37+
Write-Host "##vso[task.setvariable variable=GitHubOAuthToken;issecret=true]$token"
38+
displayName: Extract GitHub OAuth token
39+
40+
- ${{ else }}:
41+
- template: ../templates/checkout-shallow.yml
2042

2143
- template: ../templates/prepare-js-env.yml
2244

@@ -28,6 +50,9 @@ jobs:
2850

2951
- script: yarn validate-overrides
3052
displayName: yarn validate-overrides
53+
${{ if eq(parameters.buildEnvironment, 'Continuous') }}:
54+
env:
55+
PLATFORM_OVERRIDE_GITHUB_TOKEN: $(GitHubOAuthToken)
3156

3257
- script: npx unbroken -q --local-only --allow-local-line-sections
3358
displayName: check local links in .md files
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Checkout the state of the repo at the time of the commit being tested,
22
# without full history.
3+
parameters:
4+
- name: persistCredentials
5+
type: boolean
6+
default: false
7+
38
steps:
49
- checkout: self
510
fetchDepth: 1
611
clean: false
712
submodules: false
813
lfs: false
14+
persistCredentials: ${{ parameters.persistCredentials }}

0 commit comments

Comments
 (0)