首页 文章

Gitlab CI runner无法在docker executor上共享构建源代码

提问于
浏览
1

我尝试在docker上共享构建源代码(并在其上使用git fetch),但他总是在每次运行时运行git clone(是的,我已将其配置为在CI / CD管道设置上使用git fetch) .

我只想运行一个带有作曲家更新脚本的构建阶段,以及一个带phing的测试阶段(phpunit,...) . 在构建阶段,一切正常(除了git clone),在测试阶段,他不使用先前相同的源并再次克隆源...

我知道我需要与docker容器共享我的卷,但我不知道如何使用gitlab CI来实现它!

我的conf:.gitlab-ci.yml

image: webdevops/php:centos-7-php7

stages:
  - build
  - test

build:
  script:
    - composer --working-dir=/builds/MyGroup/MyProject update

test:
  script:
    - php /builds/MyGroup/MyProject/vendor/bin/phing

编辑:经过一天的搜索,我终于找到了这个文档:https://docs.gitlab.com/runner/executors/docker.html#the-persistent-storage现在它工作正常 .

谢谢大家,

1 回答

  • 1

    除了你找到的解决方案之外,我还在这个场景中使用Artifacts(在Gitlab.com中使用共享的runners) . 构建src,将其推送到Gitlab并在下一个构建步骤下载该文件 .

    build:
      environment: production
      stage: build
      image: image_used_for_builds
      script:
        - # steps to build
      artifacts:
         name: "myapplication-${CI_BUILD_REF_NAME}-${CI_BUILD_ID}-production"
         paths:
          - vendor/src
          - run.whatever
         when: on_success
    
    
    # this step will download the preivous created files to deploy them
      deploy:
       stage: deploy
       environment: production
       script:
         - run-deploy.sh
       dependencies:
         - build # this will download the artifacts
    

    也许有人发现这个有用的例子!

相关问题