3. Configuring Advanced Artifact Handling
3.1 Caching Dependencies
Cache dependencies to accelerate build times and reduce pipeline costs.
Cache Configuration Example
stages:
- build
build:
stage: build
script:
- npm install
- npm run build
cache:
key: "$CI_COMMIT_REF_SLUG" # Identifier, ensures that different branches or tags use separate caches
paths:
- node_modules/
3.2 Retention Policies
Implement artifact retention policies to manage storage usage efficiently.
Retention Policy Example
build:
stage: build
artifacts:
expire_in: 30 days