2017-04-10 4 views
1

Gitlab CI 환경에 테스트 프로젝트 인 https://gitlab.com/khpeek/CI-test을 익숙하게 사용하려고합니다. 이 프로젝트는있는 .gitlab-ci.yml 다음GitLab CI를 Python 'onbuild'이미지와 함께 사용하면 requirements.txt의 패키지가 설치되지 않은 것으로 보입니다.

image: python:2.7-onbuild 
services: 
    - rethinkdb:latest 
test_job: 
    script: 
    - pytest 

문제는 CI 파이프 라인의 test_job 작업이 다음과 같은 오류 메시지와 함께 실패한다는 것입니다 :

Running with gitlab-ci-multi-runner 9.0.1 (a3da309) 
    on docker-auto-scale (e11ae361) 
Using Docker executor with image python:2.7-onbuild ... 
Starting service rethinkdb:latest ... 
Pulling docker image rethinkdb:latest ... 
Using docker image rethinkdb:latest ID=sha256:23ecfb08823bc5483c6a955b077a9bc82899a0df2f33899b64992345256f22dd for service rethinkdb... 
Waiting for services to be up and running... 
Using docker image sha256:aaecf574604a31dd49a9d4151b11739837e4469df1cf7b558787048ce4ba81aa ID=sha256:aaecf574604a31dd49a9d4151b11739837e4469df1cf7b558787048ce4ba81aa for predefined container... 
Pulling docker image python:2.7-onbuild ... 
Using docker image python:2.7-onbuild ID=sha256:5754a7fac135b9cae7e02e34cc7ba941f03a33fb00cf31f12fbb71b8d389ece2 for build container... 
Running on runner-e11ae361-project-3083420-concurrent-0 via runner-e11ae361-machine-1491819341-82630004-digital-ocean-2gb... 
Cloning repository... 
Cloning into '/builds/khpeek/CI-test'... 
Checking out d0937f33 as master... 
Skipping Git submodules setup 
$ pytest 
/bin/bash: line 56: pytest: command not found 
ERROR: Job failed: exit code 1 

그러나,와 저장소에 requirements.txt있다 단 하나의 라인 pytest==3.0.7가 그것에있다. 그것은 내게는 python:2.7-onbuild 이미지의 Dockerfile이지만, pip install -r requirements.txt은 빌드에서 실행되어야합니다. 그렇다면 pytest은 왜 발견되지 않습니까?

답변

1

Dockerfile에 링크하면 pip install -r requirements.txtonbuild 명령의 일부입니다. 이는 첫 번째 컨테이너에서 새 컨테이너를 만들고 여러 가지 요구 사항을 설치하려는 경우 유용합니다. 따라서 pip install -r requirements.txt 명령은 CI 파이프 라인의 컨테이너 내에서 실행되지 않습니다. 그렇다면 명령은 gitlab 저장소가 복제되기 전에 시작될 때 실행됩니다.

나는 당신이 당신의 .gitlab-ci.yml 파일을 수정 문제는 간헐적 인 것 같다이 방법

image: python:2.7-onbuild 
services: 
    - rethinkdb:latest 
test_job: 
    script: 
    - pip install -r requirements.txt 
    - pytest 
0

제안 :이 테스트를 (이 초기에 실패)를 실행 61 개의 분이 걸렸다 처음 있지만를, 지금은 약 소요 분 (아래의 화면 잡기 참조).

참고로 테스트 저장소는 https://gitlab.com/khpeek/CI-test입니다. (pip install와 함께 before_script을 추가해야만 성공할 수 있습니다.)

enter image description here