Consice, Reusable and Refactored Definitions
23%
Reusable Configuration Sections Using the "extends" Keyword
Sometimes you may find yourself repeating the same configuration in multiple jobs. This is an example:
stages:
- test
test1:
stage: test
image: alpine:latest
before_script:
- echo "Setting up the environment..."
script:
- echo "Running tests for test1..."
after_script:
- echo "Cleaning up..."
test2:
stage: test
image: alpine:latest
before_script:
- echo "Setting up the environment..."
script:
- echo "Running tests for test2..."
after_script:
- echo "Cleaning up..."
ℹ️ The keyword
before_scriptis used to define a script that runs before each job in the pipeline. The keywordafter_scriptis used to define a script that runs after each job in the pipeline.
Cloud Native CI/CD with GitLab
From Commit to Production ReadyEnroll now to unlock all content and receive all future updates for free.
