@@ -329,20 +329,35 @@ jobs:
329329 # Install mssql-tools to get sqlcmd
330330 sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
331331
332- # Test SQL Server authentication
333- echo "Testing SQL Server authentication with SA user ..."
332+ # Wait for SQL Server authentication to be ready (retry loop)
333+ echo "Waiting for SQL Server authentication to be ready ..."
334334 export PATH="$PATH:/opt/mssql-tools/bin"
335335
336- # Try to connect and run a simple query
337- if sqlcmd -S localhost -U sa -P "$(TestAppPassword)" -Q "SELECT 1 AS test" -t 30; then
338- echo "✅ SQL Server authentication successful!"
339- else
340- echo "❌ SQL Server authentication FAILED!"
341- echo "Container logs:"
342- docker logs $(docker ps -q --filter ancestor=mcr.microsoft.com/mssql/server:2022-latest)
343- exit 1
344- fi
345- displayName: Test SQL Server Authentication
336+ # Retry authentication until SQL Server finishes its internal upgrade process
337+ for i in {1..30}; do
338+ echo "Authentication attempt $i of 30..."
339+ if sqlcmd -S localhost -U sa -P "$(TestAppPassword)" -Q "SELECT 1 AS test" -t 10 >/dev/null 2>&1; then
340+ echo "✅ SQL Server authentication successful after $i attempts!"
341+ break
342+ else
343+ if [ $i -eq 30 ]; then
344+ echo "❌ SQL Server authentication FAILED after 30 attempts!"
345+ echo "Final attempt with verbose output:"
346+ sqlcmd -S localhost -U sa -P "$(TestAppPassword)" -Q "SELECT 1 AS test" -t 10
347+ echo ""
348+ echo "Container logs:"
349+ docker logs $(docker ps -q --filter ancestor=mcr.microsoft.com/mssql/server:2022-latest)
350+ exit 1
351+ else
352+ echo "Authentication failed (attempt $i), waiting 10 seconds before retry..."
353+ echo "This is normal - SQL Server may still be upgrading internal databases..."
354+ sleep 10
355+ fi
356+ fi
357+ done
358+
359+ echo "SQL Server is fully ready for authentication!"
360+ displayName: Wait for SQL Server Authentication
346361
347362 - script : |
348363 # Since pylibmc isn't supported for Python 3.12+
0 commit comments