Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 5 additions & 17 deletions eng/pipelines/common/templates/jobs/ci-run-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ parameters:

- name: operatingSystem
type: string
default: ''
values:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ensured we're defining this parameter as an enum everywhere since we're doing string comparisons to make decisions based on it.

- Linux
- Mac
- Windows
default: Windows

- name: buildConfiguration
type: string
Expand Down Expand Up @@ -134,22 +138,6 @@ jobs:
- ${{ if ne(parameters.prebuildSteps, '') }}:
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration

- powershell: |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont' need to generate a GUID and use it as a password. Our Library already has a $(Password) variable meant for SQL Server SA and User passwords.

$guid = [guid]::NewGuid().ToString()
Write-Host "##vso[task.setvariable variable=password;issecret=true]$guid"
displayName: 'Generate Password'

- powershell: |
Write-Host "Password: $(password)" # prints *** to logs when set

$variableValue = "$(password)"
if (-not [string]::IsNullOrEmpty($variableValue)) {
Write-Output "The password exists with a value."
} else {
Write-Output "The password does not exist or is empty."
}
displayName: 'Verify Password'

- ${{ if eq(parameters.referenceType, 'Project') }}:
- template: ../steps/ci-project-build-step.yml@self
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
# See the LICENSE file in the project root for more information. #
#################################################################################

# This step configures an existing SQL Server running on the local Linux host.
# For example, our 1ES Hosted Pool has images like ADO-UB20-SQL22 that come with
# SQL Server 2022 pre-installed and running.
# This step configures an existing SQL Server running on the local Linux host. For example, our 1ES
# Hosted Pool has images like ADO-UB20-SQL22 that come with SQL Server 2022 pre-installed and
# running.
#
# The SA password is set to the value of the $(Password) variable defined in the ADO Library "ADO
# Test Configuration properties", brought in by common/templates/libraries/ci-build-variables.yml.

parameters:
- name: password
type: string
default: $(password)

- name: condition
type: string
default: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
Expand All @@ -21,20 +20,20 @@ steps:
# Linux only steps
- bash: |
sudo systemctl stop mssql-server

# Password for the SA user (required)

MSSQL_SA_PW=${{parameters.password }}
MSSQL_SA_PW=$(Password)

# Product ID of the version of SQL server you're installing
# Must be evaluation, developer, express, web, standard, enterprise, or your 25 digit product key
MSSQL_PID='enterprise'

echo Running mssql-conf setup...
sudo MSSQL_SA_PASSWORD=$MSSQL_SA_PW\
MSSQL_PID=$MSSQL_PID \
/opt/mssql/bin/mssql-conf -n setup accept-eula

# Connect to server and get the version:
counter=1
errstatus=1
Expand All @@ -50,7 +49,7 @@ steps:
errstatus=$?
((counter++))
done

# Display error if connection failed:
if [ $errstatus = 1 ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
# See the LICENSE file in the project root for more information. #
#################################################################################

# This step installs the latest SQL Server 2022 onto the macOS host and
# configures it for use.
# This step installs the latest SQL Server 2022 onto the macOS host and configures it for use.
#
# The SA password is set to the value of the $(Password) variable defined in the ADO Library "ADO
# Test Configuration properties", brought in by common/templates/libraries/ci-build-variables.yml.

parameters:
- name: password
type: string
default: $(password)

- name: condition
type: string
default: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))

steps:
# macOS only steps
- bash: |
# The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it back to the pipeline user.
# The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it
# back to the pipeline user.
USER=`whoami`

SQLCMD_ERRORS=$(Agent.TempDirectory)/sqlcmd_err.log
echo $SQLCMD_ERRORS
echo "Errors will be written to: $SQLCMD_ERRORS"

# Configure the prompt to show the current timestamp so we can see how long each command takes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diagnostic to see how long each command takes. Azure DevOps refuses to consistently show timestamps.

export PS4='+ [$(date "+%Y-%m-%d %H:%M:%S")] '
set -x

# Install Docker and SQLCMD tools.
brew install colima
brew install --cask docker
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
Expand All @@ -32,12 +37,12 @@ steps:
colima start --arch x86_64
docker --version
docker pull mcr.microsoft.com/mssql/server:2022-latest

# Password for the SA user (required)
MSSQL_SA_PW=${{ parameters.password }}
MSSQL_SA_PW=$(Password)

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_SA_PW" -p 1433:1433 -p 1434:1434 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest

sleep 5

docker ps -a
Expand All @@ -50,10 +55,10 @@ steps:

# Wait 3 seconds between attempts.
delay=3

# Try up to 40 times (2 minutes) to connect.
maxAttempts=40

# Attempt counter.
attempt=1

Expand All @@ -64,18 +69,18 @@ steps:
do

echo "Waiting for SQL Server to start (attempt #$attempt of $maxAttempts)..."

sqlcmd -S 127.0.0.1 -No -U sa -P $MSSQL_SA_PW -Q "SELECT @@VERSION" >> $SQLCMD_ERRORS 2>&1

# If the command was successful, then the SQL Server is ready.
if [ $? -eq 0 ]; then
ready=1
break
fi

# Increment the attempt counter.
((attempt++))

# Wait before trying again.
sleep $delay

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ parameters:
default: $(LocalDbSharedInstanceName)

# Common parameters
- name: password
type: string
default: $(password)

- name: netcoreVersionTestUtils
type: string

- name: databaseName
type: string
default: Northwind

- name: operatingSystem
type: string
values:
- Linux
- Mac
- Windows

steps:
- ${{ if eq(parameters.operatingSystem, 'Windows') }}:
Expand All @@ -85,19 +85,14 @@ steps:
enableLocalDB: ${{parameters.enableLocalDB}}
localDbAppName: ${{parameters.localDbAppName}}
localDbSharedInstanceName: ${{parameters.localDbSharedInstanceName}}
password: ${{parameters.password}}

- ${{ elseif eq(parameters.operatingSystem, 'Linux') }}:
# Linux only steps
- template: /eng/pipelines/common/templates/steps/configure-sql-server-linux-step.yml@self
parameters:
password: ${{parameters.password}}

- ${{ elseif eq(parameters.operatingSystem, 'Mac') }}:
# macOS only steps
- template: /eng/pipelines/common/templates/steps/configure-sql-server-macos-step.yml@self
parameters:
password: ${{parameters.password}}

# Common steps
- task: DotNetCoreCLI@2
Expand Down
Loading
Loading