Bitbucket 管道 sql 服务器数据库设置端口
Bitbucket pipeline sql server database set port
我有一个必须执行 django 单元测试的 bitbucket 管道。因此,我需要一个测试数据库,它应该是一个 SQL SERVER 数据库。
管道看起来像这样:
# This is a sample build configuration for Python.
# Check our guides at https://confluence.atlassian.com/x/x4UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: python:3.7.3
pipelines:
branches:
master:
- step:
name: Setup sql
image: fabiang/sqlcmd
script:
- sqlcmd -S localhost -U sa -P $DB_PASSWORD
services:
- sqlserver
- step:
name: Run tests
caches:
- pip
script: # Modify the commands below to build your repository.
- python3 -m venv my_env
- source my_env/bin/activate
- apt-get update && apt-get install
- pip3 install -r req-dev.txt
- python3 manage.py test
- step:
name: Linter
script: # Modify the commands below to build your repository.
- pip3 install flake8
- flake8 --exclude=__init__.py migrations/
definitions:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2017-latest
variables:
ACCEPT_EULA: Y
SA_PASSWORD: $DB_PASSWORD
每次当我 运行 我得到管道时:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2726.
我尝试在本地执行此操作,但只有当我使用 -p
标记定义端口时它才有效:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong!' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
如何使管道工作? (可能定义一个端口,但如何定义?)
更新:
在结果部分的 sqlserver 选项卡上显示以下错误:
我认为问题出在您调用脚本时 - sqlcmd -S localhost -U sa -P $DB_PASSWORD
因为您的 sqlserver 尚未完全初始化。
尝试在命令前放一个sleep 10
,最好是在命令失败时添加一个错误案例sleep 5
并重试。
我有一个必须执行 django 单元测试的 bitbucket 管道。因此,我需要一个测试数据库,它应该是一个 SQL SERVER 数据库。
管道看起来像这样:
# This is a sample build configuration for Python.
# Check our guides at https://confluence.atlassian.com/x/x4UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: python:3.7.3
pipelines:
branches:
master:
- step:
name: Setup sql
image: fabiang/sqlcmd
script:
- sqlcmd -S localhost -U sa -P $DB_PASSWORD
services:
- sqlserver
- step:
name: Run tests
caches:
- pip
script: # Modify the commands below to build your repository.
- python3 -m venv my_env
- source my_env/bin/activate
- apt-get update && apt-get install
- pip3 install -r req-dev.txt
- python3 manage.py test
- step:
name: Linter
script: # Modify the commands below to build your repository.
- pip3 install flake8
- flake8 --exclude=__init__.py migrations/
definitions:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2017-latest
variables:
ACCEPT_EULA: Y
SA_PASSWORD: $DB_PASSWORD
每次当我 运行 我得到管道时:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2726.
我尝试在本地执行此操作,但只有当我使用 -p
标记定义端口时它才有效:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong!' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
如何使管道工作? (可能定义一个端口,但如何定义?)
更新:
在结果部分的 sqlserver 选项卡上显示以下错误:
我认为问题出在您调用脚本时 - sqlcmd -S localhost -U sa -P $DB_PASSWORD
因为您的 sqlserver 尚未完全初始化。
尝试在命令前放一个sleep 10
,最好是在命令失败时添加一个错误案例sleep 5
并重试。