在Gitlab中使用Docker运行时Pipenv被阻止

Peq*_*que 6 python gitlab docker gitlab-ci pipenv

我在Gitlab中创建了一个简单的项目:

https://gitlab.com/PequeX/deleteme

使用仅安装几个软件包Pipfile

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"

[packages]
requests = "*"

[requires]
python_version = "3.7"
Run Code Online (Sandbox Code Playgroud)

还有一个非常简单的.gitlab-ci.yml文件

image: peque/python-devel

before_script:
  - pipenv sync --dev

python36:
  script:
    - pipenv run pytest
Run Code Online (Sandbox Code Playgroud)

还有一个自动生成的Pipfile.lock文件。我不会在这里粘贴它,因为它不是很有趣。

现在,问题是当调用Gitlab时似乎被阻塞了pipenv sync

https://gitlab.com/PequeX/deleteme/-/jobs/171273142

日志上没有输出输出,也没有错误。它只是永远被阻止。然后,最终,它超时(因为Gitlab不允许您永远运行管道)。

有什么问题或如何成功运行pipenv sync?请注意,我想继续使用Docker Hub中的同一peque/python-devel映像,因为我需要为管道安装多个Python版本。

更新资料

尝试CI按照@Hernan Garcia在他的答案中建议的方法来设置变量,但是没有运气:

我也尝试了pipenv shell@Hernan Garcia在他的评论中建议的方法,但没有运气:

Mos*_*ein 5

正如另一个答案中提到的,定义一个空CI变量将解决构建卡住的问题。

然后,由于找不到pytest而您将面临的第二个问题,这是因为docker映像缺少which包,这使得pipenv无法找到 pytest。

最终的 gitlab-ci.yml 文件应类似于以下内容:

image: peque/python-devel

variables:
  CI: ""

before_script:
  - pipenv sync --dev
  - yum install -y which

python36:
  script:
    - pipenv run pytest
Run Code Online (Sandbox Code Playgroud)

最终输出将是:

$ pipenv run pytest
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /builds/mostafahussein/deleteme, inifile:
collected 0 items

========================= no tests ran in 0.01 seconds =========================
Run Code Online (Sandbox Code Playgroud)


关于这个问题:

termios.error: (25, 'Inappropriate ioctl for device')
Run Code Online (Sandbox Code Playgroud)

这是因为pipenv shell需要tty在不引发上述错误的情况下运行,但是 GitLab CI 不提供 tty,因为据我所知没有用户输入。所以最好使用第一种方法,即pipenv run.