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

时间:2020-04-30 04:44:36

标签: python continuous-integration gitlab gitlab-ci requirements.txt

我有一个.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都可以使用。

我该如何实现?

1 个答案:

答案 0 :(得分:2)

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

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

相关问题