Artifacts¶
Goal
Learn how to...
- define artifacts
- consume artifacts
Task 1: Pass an artifact to the next stage¶
Artifacts are useful for splitting a task in separate job. Refer to the official documentation.
Improve the pipeline by using artifacts:
- Create an artifact from the
hello
binary - Create a new stage called
test
with a job calledtest
- Call the
hello
binary as a smoke test
Afterwards check the pipeline in the GitLab UI. You should see a successful pipeline run.
Hint (Click if you are stuck)
Example for creating an artifacts:
Solution (Click if you are stuck)
.gitlab-ci.yml
:
If you want to jump to the solution, execute the following command:
Bonus 1: Define from which jobs to receive artifacts¶
Usually, artifacts are received from all jobs in the previous stages. Decide from which jobs to receive artifacts using the dependencies
keyword. See the official documentation.
Modify the job test
to consume artifacts only from the job build
.
Solution (Click if you are stuck)
.gitlab-ci.yml
:
This was just a demonstration. The changes will not be preserved in the following chapters.
Bonus 2: Passing environment variables¶
In some situations, artifacts are to heavy-weight and passing a variable would be enough. Read the documentation for passing environment variables and implement this between two jobs of your choice.
The following hint and solution are a working example.
Hint (Click if you are stuck)
Example for creating an artifact for environment variables:
Solution (Click if you are stuck)
.gitlab-ci.yml
:
This was just a demonstration. The changes will not be preserved in the following chapters.