[英]Pipenv gets blocked while running with Docker in Gitlab
我在Gitlab中创建了这个简单的项目:
https://gitlab.com/PequeX/deleteme
[[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.