Skip to content

Commit

Permalink
Retry Build Ext Utilities and Nuget Restore on failure (#2906)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel authored Oct 9, 2024
1 parent 467701e commit a852709
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ steps:
solution: build.proj
msbuildArchitecture: x64
msbuildArguments: '-t:restore'
retryCountOnTaskFailure: 1

- task: MSBuild@1
displayName: 'Build Driver [Win]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ steps:
inputs:
arguments: '-f ${{parameters.targetNetCoreVersion }}'
workingDirectory: src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.ExtUtilities
retryCountOnTaskFailure: 1

- task: DotNetCoreCLI@2
displayName: 'Create Test Database ${{parameters.databaseName }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,28 @@ steps:
Write-Host $machineName
Import-Module "sqlps"
Invoke-Sqlcmd -ServerInstance "$machineName" @"
CREATE LOGIN [${{parameters.user }}] WITH PASSWORD=N'$password',
DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;
CREATE USER [${{parameters.user }}] FROM LOGIN [${{parameters.user }}];
ALTER SERVER ROLE [sysadmin] ADD MEMBER [${{parameters.user }}];
ALTER LOGIN [${{parameters.saUser }}] ENABLE;
ALTER LOGIN [${{parameters.saUser }}] WITH PASSWORD = '$password';
$tries = 0
while ($true) {
$tries++
try {
Invoke-Sqlcmd -ServerInstance "$machineName" @"
CREATE LOGIN [${{parameters.user }}] WITH PASSWORD=N'$password',
DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;
CREATE USER [${{parameters.user }}] FROM LOGIN [${{parameters.user }}];
ALTER SERVER ROLE [sysadmin] ADD MEMBER [${{parameters.user }}];
ALTER LOGIN [${{parameters.saUser }}] ENABLE;
ALTER LOGIN [${{parameters.saUser }}] WITH PASSWORD = '$password';
"@
break
} catch {
if ($tries -ge 5) {
Write-Host "##[error]Failed to create database user after $tries tries."
break
}
Write-Host "Failed to connect to server. Retrying in 5 seconds..."
Start-Sleep -Seconds 5
}
}
displayName: 'Create SQL user [Win]'
condition: ${{parameters.condition }}
env:
Expand Down

0 comments on commit a852709

Please sign in to comment.