我在Gitlab中创建了一个简单的项目:
https://gitlab.com/PequeX/deleteme
使用Pipfile that installs only a couple of packages:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pytest = "*"
[packages]
requests = "*"
[requires]
python_version = "3.7"
还有一个非常简单的.gitlab-ci.yml
file:
image: peque/python-devel
before_script:
- pipenv sync --dev
python36:
script:
- pipenv run pytest
还有autogenerated Pipfile.lock file。我不会在这里粘贴它,因为它不是很有趣。
现在,问题在于,调用pipenv sync
时,Gitlab似乎被阻止了:
https://gitlab.com/PequeX/deleteme/-/jobs/171273142
日志上没有打印输出,也没有错误。它只是永远被阻止。然后,最终它超时(因为Gitlab不允许您永远运行管道)。
出什么问题了,或者我如何成功运行pipenv sync
?请注意,我想继续在Docker Hub中使用相同的peque/python-devel
image,因为我需要为管道安装多个Python版本。
尝试按@Hernan Garcia的回答取消设置CI
变量,但是没有运气:
我也尝试了pipenv shell
,就像@Hernan Garcia在评论中建议的那样,没有运气:
答案 0 :(得分:3)
如另一个答案中所述,定义一个空的CI
变量将解决构建卡住的问题。
然后由于找不到pytest
而将面临的第二个问题,这是因为docker映像缺少which
软件包,这使pipenv
无法找到pytest。 / p>
最终的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
。
答案 1 :(得分:1)
我可以使用以下解决方法进行修复:
https://github.com/pypa/pipenv/issues/3534#issuecomment-464510351
将以下内容添加到您的<img>
文件中以取消设置src
变量:
.gitlab-ci.yml
检查此成功作业:
https://gitlab.com/hernandanielg/deleteme/-/jobs/171342796
;)
答案 2 :(得分:0)
您需要更改文件许可权。使它具有可读性和可写性
使用chmod 777
命令。
这将赋予文件读取和写入的完整权限