Skip to content

Commit 19a3a3a

Browse files
authored
Adding Retries for InstallationCheck (Azure#23792)
* Adding Retries for InstallationCheck * PR fix * PR fix * PR fix * PR fix
1 parent a1d0cd6 commit 19a3a3a

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

eng/pipelines/templates/stages/archetype-net-release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ stages:
4343
dependsOn: Signing
4444
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-net-pr'))
4545
jobs:
46-
- job: InstallationCheck
47-
condition: ne('${{ artifact.skipPublishPackage }}', 'true')
48-
displayName: "Installation Check"
49-
steps:
50-
- download: current
51-
artifact: ${{parameters.ArtifactName}}-signed
52-
- pwsh: mkdir InstallationCheck
53-
displayName: Create Testing Directory
54-
- pwsh: |
55-
$(System.DefaultWorkingDirectory)/eng/scripts/InstallationCheck.ps1 -ArtifactsDirectory ${{parameters.ArtifactName}} -Artifact ${{artifact.name}} -PipelineWorkspace $(Pipeline.Workspace)
56-
displayName: Verify Package Installation
57-
workingDirectory: $(System.DefaultWorkingDirectory)/InstallationCheck
5846
- deployment: TagRepository
5947
displayName: "Create release tag"
6048
condition: ne(variables['Skip.TagRepository'], 'true')
@@ -69,6 +57,8 @@ stages:
6957
deploy:
7058
steps:
7159
- checkout: self
60+
- download: current
61+
artifact: ${{parameters.ArtifactName}}-signed
7262
- template: /eng/common/pipelines/templates/steps/retain-run.yml
7363
- template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml
7464
parameters:
@@ -80,6 +70,15 @@ stages:
8070
PackageName: ${{artifact.name}}
8171
ServiceName: ${{parameters.ServiceDirectory}}
8272
ForRelease: true
73+
- task: PowerShell@2
74+
inputs:
75+
filePath: $(System.DefaultWorkingDirectory)/eng/scripts/InstallationCheck.ps1
76+
pwsh: true
77+
arguments: >
78+
-ArtifactsDirectory "$(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed"
79+
-Artifact ${{artifact.name}}
80+
condition: and(succeeded(),ne('${{ artifact.skipPublishPackage }}', 'true'))
81+
displayName: Verify Package Installation
8382
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
8483
parameters:
8584
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.name}}

eng/scripts/InstallationCheck.ps1

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,36 @@ param (
66
[string] $Artifact,
77

88
[Parameter()]
9-
[string] $PipelineWorkspace
9+
[string] $RetryLimit = 30
1010
)
1111

12-
Write-Host "dotnet new console"
13-
dotnet new console
14-
$localFeed = "$PipelineWorkspace/$ArtifactsDirectory-signed/$Artifact"
15-
Write-Host "dotnet nuget add source $localFeed"
16-
dotnet nuget add source $localFeed
12+
mkdir InstallationCheck
13+
cd "InstallationCheck"
14+
15+
Write-Host "dotnet new console --no-restore"
16+
dotnet new console --no-restore
17+
$localFeed = "$ArtifactsDirectory/$Artifact"
18+
19+
$version = (Get-Content "$ArtifactsDirectory/PackageInfo/$Artifact.json" | ConvertFrom-Json).Version
1720

18-
$version = (Get-ChildItem "$localFeed/*.nupkg" -Exclude "*.symbols.nupkg" -Name).replace(".nupkg","").replace("$Artifact.","")
1921
Write-Host "dotnet add package $Artifact --version $version --no-restore"
2022
dotnet add package $Artifact --version $version --no-restore
2123
if ($LASTEXITCODE) {
22-
exit $LASTEXITCODE
24+
exit $LASTEXITCODE
2325
}
2426

25-
Write-Host "dotnet nuget locals all --clear"
26-
dotnet nuget locals all --clear
27-
28-
Write-Host "dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed"
29-
dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed
30-
if ($LASTEXITCODE) {
31-
exit $LASTEXITCODE
32-
}
27+
while ($retries++ -lt $RetryLimit) {
28+
Write-Host "dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed"
29+
dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed
30+
if ($LASTEXITCODE) {
31+
if ($retries -ge $RetryLimit) {
32+
exit $LASTEXITCODE
33+
}
34+
Write-Host "dotnet clean"
35+
dotnet clean
36+
Write-Host "Restore failed, retrying in 1 minute..."
37+
sleep 60
38+
} else {
39+
break
40+
}
41+
}

0 commit comments

Comments
 (0)