我在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"
和一个非常简单的文件
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的相同图像,因为我需要为我的管道安装多个Python版本。
更新
正如@Hernan Garcia在他的回答中所暗示的那样,他试图取消CI
变量,但没有运气:
正如赫南·加西亚(Hernan Garcia )在他的评论中所暗示的那样,我也尝试过使用pipenv shell
,但没有运气:
发布于 2019-03-06 11:16:15
正如在另一个答案中提到的,定义一个空的CI
变量将解决构建停滞的问题。
然后,由于找不到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
。
发布于 2019-03-04 08:40:43
我可以通过使用这个解决方法来解决这个问题:
https://github.com/pypa/pipenv/issues/3534#issuecomment-464510351
将以下内容添加到.gitlab-ci.yml
文件中,以取消设置CI
变量:
variables:
CI: ""
检查这个成功的工作:
https://gitlab.com/hernandanielg/deleteme/-/jobs/171342796
;)
发布于 2019-03-12 23:37:57
您需要更改文件权限。使用chmod 777
命令使其具有可读性和可写性。,这将使文件具有读写的完全权限。
https://stackoverflow.com/questions/54986407
复制