pip install -r requirements.txt in gitlab ci

时间:2017-12-22 09:47:12

标签: gitlab-ci

我现在正在通过复制最简单的案例来研究gitlab-ci。它有2个简单的步骤。它们是安装和测试,没有任何测试用例。

我的问题
我将SSH_PRIVATE_KEY添加到项目后。 pip仍然无法从github安装。

我曾尝试将echo "$SSH_PRIVATE_KEY"放到该文件中。它确实显示gitlab终端中的值。

gitlab-ci

before_script:
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh

test:
  tags:
    - poink
    - Elcolie
  script:
    - pip install -r requirements.txt
    - python manage.py test

错误:

Obtaining django-geoposition from git+git@github.com:philippbosch/django-geoposition.git@origin/django-1.11#egg=django-geoposition (from -r requirements.txt (line 7))
  Cloning git@github.com:philippbosch/django-geoposition.git (to origin/django-1.11) to ./src/django-geoposition
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Command "git clone -q git@github.com:philippbosch/django-geoposition.git /builds/sarit/poink/src/django-geoposition" failed with error code 128 in None
ERROR: Job failed: exit code 1

requirements.txt: 我使用pip-toolspip-compile执行requirements.in。然后我想改变从它编译的任何东西。

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --output-file requirements.txt requirements.in
#
-e git+git@github.com:philippbosch/django-geoposition.git@origin/django-1.11#egg=django-geoposition
-e git+git@github.com:django-money/django-money.git@master#egg=django-money
appnope==0.1.0            # via ipython
boto3==1.4.7              # via django-s3-folder-storage
botocore==1.7.47          # via boto3, s3transfer
certifi==2017.11.5        # via requests
chardet==3.0.4            # via requests
collectfast==0.5.2
decorator==4.1.2          # via ipython, traitlets
django-choices==1.6.0
django-cors-headers==2.1.0
django-countries==5.0
django-debug-toolbar==1.9.1
django-dirtyfields==1.3
django-environ==0.4.4
django-extensions==1.9.7
django-filter==1.1.0
django-guardian==1.4.9
django-reversion==2.0.10
django-s3-folder-storage==0.5
django-storages==1.6.5    # via collectfast, django-s3-folder-storage
django==1.11.7
djangorestframework-jwt==1.11.0
djangorestframework==3.7.3
docutils==0.14            # via botocore
freezegun==0.3.9
gevent==1.2.2
greenlet==0.4.12          # via gevent
gunicorn==19.7.1
idna==2.6                 # via requests
ipython-genutils==0.2.0   # via traitlets
ipython==6.2.1
jedi==0.11.0              # via ipython
jmespath==0.9.3           # via boto3, botocore
model-mommy==1.4.0
olefile==0.44             # via pillow
parso==0.1.0              # via jedi
pexpect==4.3.0            # via ipython
pickleshare==0.7.4        # via ipython
pillow==4.3.0
prompt-toolkit==1.0.15    # via ipython
psycopg2==2.7.3.2
ptyprocess==0.5.2         # via pexpect
py-moneyed==0.7.0
py==1.5.2                 # via pytest
pygments==2.2.0           # via ipython
pyjwt==1.5.3              # via djangorestframework-jwt
pytest-django==3.1.2
pytest==3.2.5             # via pytest-django
python-dateutil==2.6.1    # via botocore, freezegun
pytz==2017.3              # via django, django-dirtyfields
requests==2.18.4
rest-framework-generic-relations==1.1.0
s3transfer==0.1.11        # via boto3
simplegeneric==0.8.1      # via ipython
six==1.11.0               # via django-environ, django-extensions, django-guardian, freezegun, model-mommy, prompt-toolkit, python-dateutil, traitlets
sqlparse==0.2.4           # via django-debug-toolbar
traitlets==4.3.2          # via ipython
typing==3.6.2             # via django-extensions
urllib3==1.22             # via requests
wcwidth==0.1.7            # via prompt-toolkit
werkzeug==0.12.2

1 个答案:

答案 0 :(得分:0)

我看到的文件已经过时了。可行的版本是this

before_script:
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
  - ssh-keyscan github.com >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts
  - git config --global user.email "sarit@ccc.com"
  - git config --global user.name "sarit"

test:
  tags:
    - poink
    - Elcolie
  script:
  - pip install -r requirements.txt