Ppito
Ppito

Reputation: 75

Gitlab CI runner unabled to shared build sources on docker executor

I try to share the build sources on docker (and use a git fetch on it), but he always run a git clone on each run (and yes, I have configured it to use git fetch on CI/CD Pipelines settings).

I just want to run a build stage with a composer update script, and a test stage with phing (phpunit, ...). On the build stage everything works (excepted the git clone), and on the test stage, he doesn't use the same source that previously and clone the source again...

I know that I need to shared my volume with the docker container, but I don't know how to make it with gitlab CI !?

My 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

EDIT: after a day of search, I finally found this documentation : https://docs.gitlab.com/runner/executors/docker.html#the-persistent-storage now it works fine.

Thanks all,

Upvotes: 1

Views: 450

Answers (1)

opHasNoName
opHasNoName

Reputation: 20736

In addition to the solution you found, I use Artifacts for this scenario (using shared runners in Gitlab.com). Build the src, push it to Gitlab and download the file on next build steps.

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

Maybe someone finds this useful as example!

Upvotes: 1

Related Questions