Jobs and stages¶
Goal
Learn how to...
- create jobs
- organize them in stages
- understand when jobs in different stages are executed
Preparation¶
This workshop is based on an example hello world application written in Go. Get the code using the following command:
Task 1: Create a single job¶
Add a pipeline to build the code using the following commands:
See the official documentation about jobs.
Afterwards check the pipeline in the GitLab UI. You should see a successful pipeline run.
Hint (Click if you are stuck)
- Add a file called
.gitlab-ci.yml
in the root of the project - Add a job called
build
Solution (Click if you are stuck)
.gitlab-ci.yml
:
If you want to jump to the solution, execute the following command:
Task 2: Add a stage¶
Modify the pipeline to consist of two stages called check
and build
where the check
stage contains the following commands:
See the official documentation about stages.
Afterwards check the pipeline in the GitLab UI. You should see a successful pipeline run.
Hint (Click if you are stuck)
- Define two stages using
stages
- Add a job called
check
in the stagecheck
Solution (Click if you are stuck)
.gitlab-ci.yml
:
If you want to jump to the solution, execute the following command:
Task 3: Add parallel jobs¶
Split the job check
so that one job called lint
executes go fmt .
and another job called audit
executes go vet .
.
Afterwards check the pipeline in the GitLab UI. You should see a successful pipeline run.
Hint (Click if you are stuck)
Both jobs lint
and audit
must be in the stage check
.
Solution (Click if you are stuck)
.gitlab-ci.yml
:
If you want to jump to the solution, execute the following command: