如何在Travis CI上为SQL Server安装ODBC Driver 13?

时间:2019-03-15 17:10:49

标签: sql-server docker odbc travis-ci

我正在尝试使用Travis CI维护私有R包在私有github存储库上进行持续集成。有连接到SQL的单元测试,因此我需要安装ODBC Driver 13 for SQL Server。我已经尝试了几种在网络上使用的方法,但是都没有用。我得到的问题是Travis在某个时候尝试调用ODBC服务器,该服务器返回:

[unixODBC][Driver Manager]Data source name not found, and no default driver specified

因此,这里有一些我尝试不可行的解决方案:

  - wget https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz -P ..
  - tar xvzf ../msodbcsql-13.0.0.0.tar.gz -C ..
  - sed -i '14d' ../msodbcsql-13.0.0.0/build_dm.sh
  - sed -i '/tmp=/ctmp=/tmp/odbcbuilds'  ../msodbcsql-13.0.0.0/build_dm.sh  
  - ../msodbcsql-13.0.0.0/build_dm.sh --accept-warning

给予:

[0K$ wget https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz -P ..
--2019-03-14 16:28:05--  https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz
Resolving download.microsoft.com (download.microsoft.com)... 23.35.205.15, 2600:1404:27:783::e59, 2600:1404:27:78d::e59
Connecting to download.microsoft.com (download.microsoft.com)|23.35.205.15|:443... connected.
HTTP request sent, awaiting response... 404 Not Found

足够公平...链接已断开。下一步:

 - sudo su
 -  sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release/ xenial main" > /etc/apt/sources.list.d/mssqlpreview.list'
 - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893

^不能像这样声明sudo,显然没有sudo的东西是行不通的。下一步:

addons:
  apt:
    packages:
      - libudunits2-dev

script:
  - docker run --net=host -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw0rd' -d microsoft/mssql-server-linux:2017-latest
  - echo "Running docker for commit $TRAVIS_COMMIT"

这似乎也不起作用。还尝试了随机Docker版本:

- docker pull microsoft/mssql-server-linux:2017-latest

在这一点上,我基本上正在尝试可以尝试的任何事情。还有其他建议吗?

编辑:这是Jan回答的结果:

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试以下命令以安装最新版本:

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y curl add-apt-key apt-transport-https
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssqlrelease.list
apt-get update
ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get install -y msodbcsql mssql-tools

在以下命令之后安装了msodbcsql个软件包:

$ apt list --installed | grep msodbcsql

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

msodbcsql/xenial,now 13.1.9.2-1 amd64 [installed]
msodbcsql17/xenial,now 17.3.1.1-1 amd64 [installed,automatic]

如果您需要确切的版本13.0.0.0,则需要自定义已安装的软件包版本。