xxxxxxxxxx
### How archiving and extracting works[](https://docs.gitlab.com/ee/ci/caching/index.html#common-use-cases-for-caches#how-archiving-and-extracting-works "Permalink")
This example shows two jobs in two consecutive stages:
```
stages:
- build
- test
before_script:
- echo "Hello"
job A:
stage: build
script:
- mkdir vendor/
- echo "build" > vendor/hello.txt
cache:
key: build-cache
paths:
- vendor/
after_script:
- echo "World"
job B:
stage: test
script:
- cat vendor/hello.txt
cache:
key: build-cache
paths:
- vendor/
```
If one machine has one runner installed, then all jobs for your project run on the same host:
1. Pipeline starts.
2. `job A` runs.
3. `before_script` is executed.
4. `script` is executed.
5. `after_script` is executed.
6. `cache` runs and the `vendor/` directory is zipped into `cache.zip`. This file is then saved in the directory based on the [runner’s setting](https://docs.gitlab.com/ee/ci/caching/index.html#common-use-cases-for-caches#where-the-caches-are-stored) and the `cache: key`.
7. `job B` runs.
8. The cache is extracted (if found).
9. `before_script` is executed.
10. `script` is executed.
11. Pipeline finishes.
xxxxxxxxxx
stages:
- build
- deploy
variables:
DIR_PATH: "${CI_COMMIT_REF_NAME}_PATH"
before_script:
- cp $SSH_KEY ~/.ssh/id_rsa
- chmod 700 ~/.ssh
- chmod 600 ~/.ssh/id_rsa
- DIR=${!DIR_PATH}
Pull repository:
stage: build
script:
- ssh $SSH_HOST bash $DIR/git.sh
only:
- development
- production
- pre-production
Fix Coding Standards:
stage: build
script:
- ssh $SSH_HOST bash $DIR/cs_fix.sh
only:
- development
- production
- pre-production
Install dependencies:
stage: build
script:
- ssh $SSH_HOST bash $DIR/dependency.sh
only:
- development
- production
- pre-production
Deploy changes:
stage: deploy
script:
- ssh $SSH_HOST bash $DIR/deploy.sh
only:
- development
- production
- pre-production