@@ -77,110 +77,6 @@ steps:
7777 displayName : ' CodeQL Initialize'
7878 condition : eq(variables['Codeql.enabled'], 'True')
7979
80- - pwsh : |
81- # setup docker image for SQL 2025
82-
83- # Switch to Linux containers if currently on Windows
84- $currentOs = docker version --format '{{.Server.Os}}'
85- Write-Host "Current Docker OS: $currentOs"
86-
87- if ($currentOs -match "windows") {
88- Write-Host "Switching to Linux containers..."
89-
90- $dockerCli = "DockerCli.exe"
91- $found = $false
92-
93- # Check PATH
94- Write-Host "Checking for DockerCli.exe in PATH..."
95- if (Get-Command $dockerCli -ErrorAction SilentlyContinue) {
96- Write-Host "Found DockerCli.exe in PATH."
97- $found = $true
98- } else {
99- Write-Host "DockerCli.exe not found in PATH."
100- }
101-
102- # Check standard installation path
103- if (-not $found) {
104- $standardPath = "C:\Program Files\Docker\Docker\DockerCli.exe"
105- Write-Host "Checking for DockerCli.exe at: $standardPath"
106- if (Test-Path $standardPath) {
107- Write-Host "Found DockerCli.exe at $standardPath"
108- $dockerCli = $standardPath
109- $found = $true
110- } else {
111- Write-Host "DockerCli.exe not found at $standardPath"
112- }
113- }
114-
115- # Check relative to docker.exe
116- if (-not $found) {
117- $dockerPath = (Get-Command docker).Source
118- Write-Host "docker.exe found at: $dockerPath"
119- $dockerDir = Split-Path $dockerPath
120-
121- # Check same directory
122- $sameDirPath = Join-Path $dockerDir "DockerCli.exe"
123- Write-Host "Checking for DockerCli.exe at: $sameDirPath"
124- if (Test-Path $sameDirPath) {
125- Write-Host "Found DockerCli.exe at $sameDirPath"
126- $dockerCli = $sameDirPath
127- $found = $true
128- }
129-
130- # Check 2 levels up
131- if (-not $found) {
132- $potentialPath = Join-Path (Split-Path (Split-Path $dockerDir)) "DockerCli.exe"
133-
134- Write-Host "Checking for DockerCli.exe at: $potentialPath"
135- if (Test-Path $potentialPath) {
136- Write-Host "Found DockerCli.exe at $potentialPath"
137- $dockerCli = $potentialPath
138- $found = $true
139- } else {
140- Write-Host "DockerCli.exe not found at $potentialPath"
141- }
142- }
143- }
144-
145- if ($found) {
146- & $dockerCli -SwitchDaemon
147- Start-Sleep -Seconds 10
148- Write-Host "New Docker OS: $(docker version --format '{{.Server.Os}}')"
149- } else {
150- Write-Error "Could not find DockerCli.exe to switch to Linux containers."
151- }
152- }
153-
154- # generate random password of 24 characters, save to a script variable
155- $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%^&*()'
156- $password = -join (1..24 | ForEach-Object { $chars[(Get-Random -Maximum $chars.Length)] })
157-
158- # pull docker image for SQL 2025
159- docker pull mcr.microsoft.com/mssql/server:2025-latest
160-
161- # set up docker container for SQL 2025 using that password
162- docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$password" -p 1433:1433 --name sql2025 -d mcr.microsoft.com/mssql/server:2025-latest
163-
164- # Wait for SQL Server to be ready
165- $start = Get-Date
166- $timeout = New-TimeSpan -Seconds 60
167- do {
168- Start-Sleep -Seconds 2
169- $logs = docker logs sql2025 2>&1
170- if ($logs -match "SQL Server is now ready for client connections") {
171- Write-Host "SQL Server is ready."
172- break
173- }
174- if ((Get-Date) - $start -gt $timeout) {
175- Write-Error "Timeout waiting for SQL Server to start."
176- exit 1
177- }
178- } while ($true)
179-
180- # Verify connection and print version
181- docker exec sql2025 /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$password" -Q "SELECT @@VERSION"
182- displayName : ' Setup Docker image for integration tests'
183-
18480- task : BatchScript@1
18581 displayName : ' Run script build.cmd'
18682 inputs :
0 commit comments