Gitlab-Runner/Git is removing content build folder

For a project I have a static website with 2 CI jobs (build/bundle Javascript, deploy static html + javascript on a S3 bucket).
The build and deploy jobs both work. Only at the beginning of the deploy job, GIT is fetching changes + removing the content of my build folder.

What am I doing wrong?

My .gitlab-ci.yml file

image: node:5.1.1

before_script:

  • apt-get update -yqq
  • apt-get install git -yqq

stages:

  • build
  • deploy

job1:
stage: build
script:

  • npm install
  • npm run build
    cache:
    paths:
    • dist/

job2:
stage: deploy
script:
- apt-get update -yq
- apt-get install ruby-full -yqq
- apt-get install rubygems-integration -yqq
- gem install dpl
- dpl --provider=s3 --access-key-id=$S3_STAGING_KEY_ID --secret-access-key=$S3_STAGING_ACCESS_KEY --region=eu-west-1 --local-dir=dist --bucket=BUCKETNAME --acl=public_read
type: deploy
except:
- stable
artifacts:
paths:
- dist/
only:
- master

First lines Deploy job

gitlab-ci-multi-runner 0.7.2 (998cf5d)
Using Docker executor with image node:5.1.1 …
Pulling docker image gitlab/gitlab-runner:build …
Pulling docker image node:5.1.1 …

Running on runner-9198775b-project-4-concurrent-0 via ip-10-0-0-154…
Fetching changes…
Removing dist/index.html
Removing dist/static/
Removing node_modules/
HEAD is now at ea0ff12 Add cache
Checking out ea0ff123 as master…
HEAD is now at ea0ff12… Add cache

apt-get update -yqq apt-get install git -yqq
$ apt-get update -yq

I think that because this is not set globally, the second job doesn’t pick the cache dir.

You can try moving

cache:
  paths:
    - dist/

outside the job’s scope and put it under the image declaration.

Still not working :confused:

gitlab-ci-multi-runner 0.7.2 (998cf5d)
Using Docker executor with image node:5.1.1 …
Pulling docker image gitlab/gitlab-runner:build …
Pulling docker image node:5.1.1 …

Running on runner-9198775b-project-4-concurrent-0 via ip-10-0-0-154…
Fetching changes…
> Removing dist/index.html
> Removing dist/static/
Removing node_modules/
HEAD is now at 02a2224 Fix cache issue
Checking out 02a22242 as master…
HEAD is now at 02a2224… Fix cache issue

Ok I also misunderstood how the cache feature works. See this issue https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336

What you want is not implemented yet.