繁体   English   中英

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

[英]Pipenv gets blocked while running with Docker in Gitlab

我在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"

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

image: peque/python-devel

before_script:
  - pipenv sync --dev

python36:
  script:
    - pipenv run pytest

还有自动生成的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在他的评论中建议,没有运气:

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

然后你将面临的第二个问题是由于没有找到pytest ,这是因为pytest镜像缺少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

最终输出将是:

$ 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 =========================


关于这个问题:

 termios.error: (25, 'Inappropriate ioctl for device') 

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

我可以通过使用此解决方法来修复它:
https://github.com/pypa/pipenv/issues/3534#issuecomment-464510351

将以下内容添加到.gitlab-ci.yml文件中以取消设置CI变量:

variables:
    CI: ""

检查这个成功的工作:
https://gitlab.com/hernandanielg/deleteme/-/jobs/171342796

;)

您需要更改文件权限。 使用chmod 777命令使其成为可读写的。 这将为文件提供读写的完全权限

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM