Defaults¶
Goal
Learn how to...
- avoid repetition in jobs
- specify defaults are the top of your pipeline
Task: Don't repeat yourself¶
All jobs currently have a dedicated image
directive. Using defaults, this repetition can be avoided. See the official documentation.
Replace job specific image
directives with the default
directive.
Afterwards check the pipeline in the GitLab UI. You should see a successful pipeline run.
Hint (Click if you are stuck)
- Remove
image
from all build jobs - Add
default
with theimage
directive at the top
Solution (Click if you are stuck)
.gitlab-ci.yml
:
If you want to jump to the solution, execute the following command:
Bonus 1: Override defaults¶
Jobs can still choose to use an image different from the default:
- Add a new job
- Add an
image
directory to the new job - Specify a different image
- Check out how the executation environment changes
Bonus 2: Default values for variables¶
See the official documentation for default
as well as variables
and check how they are related.
Solution (Click if you are stuck)
Global variables are not located under default
but under the global variables
keyword.