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

标签 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可以使用。

我怎样才能做到这一点?

最佳答案

如果 requirements.txt,我发现一种非常有效的选择文件变化不大,就是将它烘焙到自己的Docker镜像中。

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

关于python - 如何避免在 .gitlab-ci.yml 的每个阶段之前安装 requirements.txt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61516089/

相关文章:

android-studio - jmockit与android studio下的gradle

mercurial - 您使用哪种持续集成软件?

java - 如何使用自己的运行器在 gitlab 作业中将 Postgres 作为服务运行?

python - 远大前程 : base_directory must be an absolute path if root_directory is not provided

python - 谷歌 foobar gearing_up_for_destruction

python - 如何在 Python 2 中求大数的平方根?

python - 计算列表元组中每个列表中给定单词的出现次数

continuous-integration - 为什么 Jenkins 告诉我升级到 Hudson?

git - 将存储库从 Github 迁移到自托管 Gitlab 时更新和修复 LFS

linux - Gitlab nginx 问题 - nginx : [emerg] bind() to 0. 0.0.0:80 failed (98: Address already in use)