Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Retries for InstallationCheck #23792

Merged
merged 5 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 6 additions & 12 deletions eng/pipelines/templates/stages/archetype-net-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ stages:
dependsOn: Signing
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-net-pr'))
jobs:
- job: InstallationCheck
condition: ne('${{ artifact.skipPublishPackage }}', 'true')
displayName: "Installation Check"
steps:
- download: current
artifact: ${{parameters.ArtifactName}}-signed
- pwsh: mkdir InstallationCheck
displayName: Create Testing Directory
- pwsh: |
$(System.DefaultWorkingDirectory)/eng/scripts/InstallationCheck.ps1 -ArtifactsDirectory ${{parameters.ArtifactName}} -Artifact ${{artifact.name}} -PipelineWorkspace $(Pipeline.Workspace)
displayName: Verify Package Installation
workingDirectory: $(System.DefaultWorkingDirectory)/InstallationCheck
- deployment: TagRepository
displayName: "Create release tag"
condition: ne(variables['Skip.TagRepository'], 'true')
Expand All @@ -69,6 +57,8 @@ stages:
deploy:
steps:
- checkout: self
- download: current
artifact: ${{parameters.ArtifactName}}-signed
- template: /eng/common/pipelines/templates/steps/retain-run.yml
- template: /eng/common/pipelines/templates/steps/set-test-pipeline-version.yml
parameters:
Expand All @@ -80,6 +70,10 @@ stages:
PackageName: ${{artifact.name}}
ServiceName: ${{parameters.ServiceDirectory}}
ForRelease: true
- pwsh: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is just calling a single script lets switch it to using the powershell tasks instead of the pwsh shortcut. See https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/2/Azure-DevOps-Pipeline-Guidance?anchor=devops-tasks-vs-pwsh-script-shortcut for more info.

$(System.DefaultWorkingDirectory)/eng/scripts/InstallationCheck.ps1 -ArtifactsDirectory "$(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed" -Artifact ${{artifact.name}}
condition: and(succeeded(),ne('${{ artifact.skipPublishPackage }}', 'true'))
displayName: Verify Package Installation
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
parameters:
ArtifactLocation: $(Pipeline.Workspace)/${{parameters.ArtifactName}}-signed/${{artifact.name}}
Expand Down
44 changes: 28 additions & 16 deletions eng/scripts/InstallationCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,39 @@ param (
[string] $Artifact,

[Parameter()]
[string] $PipelineWorkspace
[string] $PipelineWorkspace,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like we need or use the PipelineWorkspace variable any longer so we should remove it.


[Parameter()]
[string] $RetryLimit = 30
)

Write-Host "dotnet new console"
dotnet new console
$localFeed = "$PipelineWorkspace/$ArtifactsDirectory-signed/$Artifact"
Write-Host "dotnet nuget add source $localFeed"
dotnet nuget add source $localFeed
mkdir InstallationCheck
cd "InstallationCheck"

Write-Host "dotnet new console --no-restore"
dotnet new console --no-restore
$localFeed = "$ArtifactsDirectory/$Artifact"

$version = (Get-Content "$ArtifactsDirectory/PackageInfo/$Artifact.json" | ConvertFrom-Json).Version

$version = (Get-ChildItem "$localFeed/*.nupkg" -Exclude "*.symbols.nupkg" -Name).replace(".nupkg","").replace("$Artifact.","")
Write-Host "dotnet add package $Artifact --version $version --no-restore"
dotnet add package $Artifact --version $version --no-restore
if ($LASTEXITCODE) {
exit $LASTEXITCODE
exit $LASTEXITCODE
}

Write-Host "dotnet nuget locals all --clear"
dotnet nuget locals all --clear

Write-Host "dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed"
dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed
if ($LASTEXITCODE) {
exit $LASTEXITCODE
}
while ($retries++ -lt $RetryLimit) {
Write-Host "dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed"
dotnet restore -s https://api.nuget.org/v3/index.json -s $localFeed --no-cache --verbosity detailed
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
if ($LASTEXITCODE) {
if ($retries -ge $RetryLimit) {
exit $LASTEXITCODE
}
Write-Host "dotnet clean"
dotnet clean
Write-Host "Restore failed, retrying in 1 minute..."
sleep 60
} else {
break
}
}