Skip to content

Commit

Permalink
Add retry on failure for all upload tasks in Azure Pipelines (#19761)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapatwardhan authored and josea committed Jun 19, 2023
1 parent 592e2f0 commit b608697
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vsts-ci/linux/templates/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ jobs:
Write-Host "##vso[artifact.upload containerfolder=rpm;artifactname=rpm]$packagePath"
}
displayName: Upload packages
retryCountOnTaskFailure: 2
11 changes: 11 additions & 0 deletions src/System.Management.Automation/help/UpdateHelpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Help;
using System.Management.Automation.Internal;
Expand Down Expand Up @@ -181,6 +182,16 @@ protected override void ProcessRecord()

_isInitialized = true;
}

// check if there is an UI, if not Throw out terminating error.
var cultures = _language ?? _helpSystem.GetCurrentUICulture();
if (!cultures.Any())
{
string cultureString = string.IsNullOrEmpty(CultureInfo.CurrentCulture.Name) ? CultureInfo.CurrentCulture.DisplayName : CultureInfo.CurrentCulture.Name;
string errMsg = StringUtil.Format(HelpDisplayStrings.FailedToUpdateHelpWithLocaleNoUICulture, cultureString);
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "FailedToUpdateHelpWithLocaleNoUICulture", ErrorCategory.InvalidOperation, null);
ThrowTerminatingError(error);
}

base.Process(_module, FullyQualifiedModule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ English-US help content is available and can be saved using: Save-Help -UICultur
<value>Failed to update Help for the module(s) '{0}' with UI culture(s) {{{1}}} : {2}.
English-US help content is available and can be installed using: Update-Help -UICulture en-US.</value>
</data>
<data name="FailedToUpdateHelpWithLocaleNoUICulture" xml:space="preserve">
<value>Your culture is ({0}), which is a default not associated with any language, consider changing your system culture or install the English-US help content using: Update-Help -UICulture en-US.</value>
</data>
<data name="FalseShort" xml:space="preserve">
<value>false</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ Describe "Validate 'Update-Help' shows 'HelpCultureNotSupported' when thrown" -T
@{ 'name' = 'explicit culture de-DE'; 'culture' = 'de-DE' }
) {
param ($name, $culture)

# if running in Linux as an invariant culture => force Spanish
if ($IsLinux && $culture -eq $null && (Get-Culture).LCID -eq 127 ){
$culture = 'es-ES'
}

# Cannot pass null, have to splat to skip argument entirely
$cultureArg = $culture ? @{ 'UICulture' = $culture } : @{}
$cultureUsed = $culture ?? (Get-Culture)
Expand All @@ -431,6 +437,15 @@ Describe "Validate 'Update-Help' shows 'HelpCultureNotSupported' when thrown" -T
}
}

Describe "Validate 'Update-Help' shows 'FailedToUpdateHelpWithLocaleNoUICulture' when no language in culture" -Tags @('Feature') {

It 'Shows error if culture language is not specified for the current system:' -Skip:(($IsLinux -eq $false) || ((Get-Culture).LCID -ne 127)) {
{
Update-Help
} | Should -Throw -ErrorId "FailedToUpdateHelpWithLocaleNoUICulture"
}
}

Describe "Validate 'Save-Help -DestinationPath for one PowerShell modules." -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$SavedProgressPreference = $ProgressPreference
Expand Down
1 change: 1 addition & 0 deletions tools/releaseBuild/azureDevOps/releaseBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,6 @@ stages:
Get-Content "$(Build.StagingDirectory)\release.json"
Write-Host "##vso[artifact.upload containerfolder=metadata;artifactname=metadata]$(Build.StagingDirectory)\release.json"
displayName: Create and upload release.json file to build artifact
retryCountOnTaskFailure: 2
- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ jobs:
inputs:
pathToPublish: '$(Build.SourcesDirectory)/ReleaseFileHash.csv'
artifactName: ReleaseFilesHash
retryCountOnTaskFailure: 2

- task: securedevelopmentteam.vss-secure-development-tools.build-task-apiscan.APIScan@2
displayName: 'Run APIScan'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: $(tpnContainer)
resourceGroup: '$(StorageResourceGroup)'
retryCountOnTaskFailure: 2

- task: PublishPipelineArtifact@1
inputs:
targetPath: $(System.ArtifactsDirectory)
artifactName: notice
displayName: Publish notice artifacts
condition: always()
retryCountOnTaskFailure: 2
6 changes: 6 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/linux-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ jobs:
displayName: Publish artifacts
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
retryCountOnTaskFailure: 2
- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml

Expand Down Expand Up @@ -388,6 +390,7 @@ jobs:
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
retryCountOnTaskFailure: 2

- template: upload-final-results.yml
parameters:
Expand All @@ -403,6 +406,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)-gc'
condition: and(eq(variables['buildName'], 'DEB'), succeeded())
retryCountOnTaskFailure: 2

- template: upload-final-results.yml
parameters:
Expand All @@ -419,6 +423,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(and(succeeded(), ne(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
retryCountOnTaskFailure: 2

# requires windows
- task: AzureFileCopy@4
Expand All @@ -430,6 +435,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
retryCountOnTaskFailure: 2

- template: upload-final-results.yml
parameters:
Expand Down
14 changes: 14 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,81 +160,95 @@ jobs:
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild.tar.gz'
artifactName: pwshLinuxBuild.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild-meta'
artifactName: pwshLinuxBuild-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildMinSize.tar.gz'
artifactName: pwshLinuxBuildMinSize.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildMinSize-meta'
artifactName: pwshLinuxBuildMinSize-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm32.tar.gz'
artifactName: pwshLinuxBuildArm32.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm32-meta'
artifactName: pwshLinuxBuildArm32-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm64.tar.gz'
artifactName: pwshLinuxBuildArm64.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'deb') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm64-meta'
artifactName: pwshLinuxBuildArm64-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'rpm') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshMarinerBuildAmd64.tar.gz'
artifactName: pwshMarinerBuildAmd64.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'rpm') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshMarinerBuildAmd64-meta'
artifactName: pwshMarinerBuildAmd64-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'alpine') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild.tar.gz'
artifactName: pwshLinuxBuildAlpine.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'alpine') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild-meta'
artifactName: pwshLinuxBuildAlpine-meta
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'fxdependent') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild.tar.gz'
artifactName: pwshLinuxBuildFxdependent.tar.gz
retryCountOnTaskFailure: 2

- ${{ if eq(variables.build,'fxdependent') }} :
- task: PublishPipelineArtifact@1
inputs:
path: '$(System.ArtifactsDirectory)/pwshLinuxBuild-meta'
artifactName: pwshLinuxBuildFxdependent-meta
retryCountOnTaskFailure: 2
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
displayName: Compress signed files
retryCountOnTaskFailure: 2
- pwsh: |
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(succeeded(), ne(variables['SHOULD_SIGN'], 'true'))
retryCountOnTaskFailure: 2

- task: AzureFileCopy@4
displayName: 'AzureBlob File Copy - signed'
Expand All @@ -123,6 +124,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
retryCountOnTaskFailure: 2

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
Expand Down
2 changes: 2 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)-nuget'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
retryCountOnTaskFailure: 2

- task: AzureFileCopy@4
displayName: 'Upload global tool packages to Azure'
Expand All @@ -272,6 +273,7 @@ jobs:
ContainerName: 'tool'
blobPrefix: '$(Version)'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
retryCountOnTaskFailure: 2

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ steps:
storage: '$(StorageAccount)'
ContainerName: BuildInfo
condition: and(succeeded(), eq(variables['CopyMainBuildInfo'], 'YES'))
retryCountOnTaskFailure: 2

- task: AzureFileCopy@4
displayName: 'AzureBlob build info ''lts.json'' Copy when needed'
Expand All @@ -87,6 +88,7 @@ steps:
storage: '$(StorageAccount)'
ContainerName: BuildInfo
condition: and(succeeded(), eq(variables['CopyLTSBuildInfo'], 'YES'))
retryCountOnTaskFailure: 2

- task: AzureFileCopy@4
displayName: 'AzureBlob build info ''Major-Minor.json'' Copy when needed'
Expand All @@ -97,3 +99,4 @@ steps:
storage: '$(StorageAccount)'
ContainerName: BuildInfo
condition: and(succeeded(), eq(variables['CopyVersionBuildInfo'], 'YES'))
retryCountOnTaskFailure: 2
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: ps-deps-json
blobPrefix: '$(BlobPrefix)'
retryCountOnTaskFailure: 2
4 changes: 4 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/sign-build-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ steps:
Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadTarFilePath"
displayName: Upload signed tar.gz files to artifacts
condition: eq(variables['ArtifactPlatform'], 'linux')
retryCountOnTaskFailure: 2


- pwsh: |
$uploadFolder = '$(BinPath)'
Expand All @@ -320,5 +322,7 @@ steps:
Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadZipFilePath"
displayName: Upload signed zip files to artifacts
condition: eq(variables['ArtifactPlatform'], 'windows')
retryCountOnTaskFailure: 2


- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml
2 changes: 2 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/signBuildFiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,5 @@ steps:
Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadTarFilePath"
displayName: ${{ parameters.buildPrefixName }} - Upload signed files to artifacts
retryCountOnTaskFailure: 2

Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ steps:
}
displayName: Upload ${{ parameters.artifactName }} Artifacts ${{ parameters.artifactFilter }} from ${{ parameters.artifactPath }}
condition: ${{ parameters.condition }}
retryCountOnTaskFailure: 2
4 changes: 4 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ steps:
ContainerName: '$(AzureVersion)'
resourceGroup: '$(StorageResourceGroup)'
condition: succeeded()
retryCountOnTaskFailure: 2

- task: AzureFileCopy@4
displayName: 'upload signed min-size package (for Guest Config) to Azure - ${{ parameters.architecture }}'
Expand All @@ -32,6 +33,7 @@ steps:
ContainerName: '$(AzureVersion)-gc'
resourceGroup: '$(StorageResourceGroup)'
condition: and(eq('${{ parameters.architecture }}', 'x64'), succeeded())
retryCountOnTaskFailure: 2

- template: upload-final-results.yml
parameters:
Expand All @@ -49,6 +51,7 @@ steps:
ContainerName: '$(AzureVersion)-private'
resourceGroup: '$(StorageResourceGroup)'
condition: and(succeeded(), eq('${{ parameters.msi }}', 'yes'))
retryCountOnTaskFailure: 2

# Disable upload task as the symbols package is not currently used and we want to avoid publishing this in releases
#- task: AzureFileCopy@4
Expand Down Expand Up @@ -77,3 +80,4 @@ steps:
ContainerName: '$(AzureVersion)-private'
resourceGroup: '$(StorageResourceGroup)'
condition: and(succeeded(), eq('${{ parameters.msix }}', 'yes'), eq(variables['SHOULD_SIGN'], 'true'))
retryCountOnTaskFailure: 2
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ jobs:
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
displayName: Compress signed files
retryCountOnTaskFailure: 2
- pwsh: |
$runtime = switch ($env:Architecture)
Expand Down Expand Up @@ -268,6 +270,7 @@ jobs:
Write-Host "##vso[artifact.upload containerfolder=signed;artifactname=signed]$packagePath"
}
displayName: Upload unsigned packages
retryCountOnTaskFailure: 2
- ${{ if and(ne(variables['BuildConfiguration'],'minSize'), in(variables['Architecture'], 'x64', 'x86')) }}:
- template: EsrpSign.yml@ComplianceRepo
Expand All @@ -289,6 +292,7 @@ jobs:
Write-Host "##vso[artifact.upload containerfolder=finalResults;artifactname=finalResults]$packagePath"
}
displayName: Upload signed MSI to finalResults
retryCountOnTaskFailure: 2
- task: AzureFileCopy@4
displayName: 'upload signed msi to Azure - ${{ parameters.architecture }}'
Expand All @@ -299,6 +303,7 @@ jobs:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
resourceGroup: '$(StorageResourceGroup)'
retryCountOnTaskFailure: 2

- pwsh: |
cd $(PowerShellRoot)
Expand Down Expand Up @@ -345,6 +350,7 @@ jobs:
Write-Host "##vso[artifact.upload containerfolder=signed;artifactname=signed]$packagePath"
}
displayName: Upload unsigned exe
retryCountOnTaskFailure: 2
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
Expand Down

0 comments on commit b608697

Please sign in to comment.