我第一次尝试使用 gitlab CI。我只想在其上测试(而不是部署)一个 Python 程序。我不知道为什么,但它在 pip 上失败了,找不到...
这是 gitlab 的错误信息:
Skipping Git submodules setup
$ pip install -r requirements.txt
/bin/bash: line 71: pip: command not found
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)
这里是我的 .gitlab-ci.yaml:
stages:
- build
- test
myJob:
stage: build
image: python:3.6
script:
- apt-get update -q -y
- apt-get install -y python-pip
- python -V
- echo "hello world"
- pip install -r requirements.txt
myJob2:
stage: test
script:
- python test.py
Run Code Online (Sandbox Code Playgroud)
hello world 和 Python 版本都没有打印出来。所以我可能犯了一个基本错误,但哪一个?
管道中的不同作业在不同的容器中运行。准确地说,它们在您指定为 的容器中运行image
。该作业myJob
在python:3.6
容器内运行,因此您拥有pip
命令并且一切正常。
对于您的第二个作业 ( myJob2
),您没有指定任何图像,因此将使用默认图像,该图像可能不是 Python 图像。
即使您的第二个作业在python
容器内运行,它仍然会因为缺少依赖项而失败。您正在第一个作业中安装依赖项,但您没有指定应传递给下一个作业的任何工件。有关传递这些工件的更多信息,请查看Gitlab CI 参考。
以下.gitlab-ci.yml
应该工作:
stages:
- build
- test
myJob:
stage: build
image: python:3.6
script:
- apt-get update -q -y
- apt-get install -y python-pip
- python -V
- echo "hello world"
- pip install -r requirements.txt
artifacts:
untracked: true
myJob2:
stage: test
image: python:3.6
script:
- python test.py
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4349 次 |
最近记录: |