如何避免在.gitlabci.yml的每个阶段之前安装requirements.txt?

2024-09-29 20:26:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个.gitlab-ci.yml看起来像这样:

image: "python:3.7"

before_script:
  - pip install -r requirements.txt

stages:
  - stageA
  - stageB

stage_a:
  stage: stageA
  script:
  - run_some_python_scripts

stage_b:
  stage: stageB
  script:
  - run_more_python_scripts

通过这种设置,在每个阶段之前都会安装requirements.txt。 我只需要安装一次,这样stageAstageB都可以使用

我怎样才能做到这一点


Tags: installpiprunimagetxtciymlgitlab
1条回答
网友
1楼 · 发布于 2024-09-29 20:26:01

我发现,如果requirements.txt文件没有太大变化,那么将其烘焙到您自己的Docker映像中是一个很好的选择

我个人不太喜欢的另一种选择是使用virtualenv,然后在virtualenv上使用GitLab的cache,但是如果有很多pip包,这可能会有点慢

相关问题 更多 >

    热门问题