In GitLab CI, artifacts are files or directories generated by a job during the pipeline execution that are saved and shared with other jobs or stages in the pipeline. These artifacts could be build outputs, test results, logs, or any other files that you want to preserve and use later in the pipeline or after the pipeline completes.
Artifacts are typically used to:
- Share build results between jobs (e.g., use the build output in deployment jobs).
- Save logs, test results, or coverage reports for later analysis.
- Allow downloading of the results from the GitLab interface.
Key Points:
- Artifacts are defined within a job in the
.gitlab-ci.yml
file. - They are uploaded to GitLab after the job finishes and can be downloaded via the GitLab UI.
- You can set an expiration time for artifacts, after which they are automatically deleted.
Example:
In the .gitlab-ci.yml
file:
job_name:
script:
- build_command
artifacts:
paths:
- build/output/
expire_in: 1 week
In this example:
job_name
will run a build command.- The
build/output/
folder will be saved as an artifact. - The artifact will expire and be deleted after 1 week.
I can create a visual representation of this concept to better explain it. Let me do that for you!
It seems there was an issue generating the image. However, I can explain the concept visually:
GitLab CI Pipeline with Artifacts
-
Job 1: This job compiles or builds your code, for example.
- It produces artifact files such as logs, compiled binaries, or reports.
-
Artifact Storage: After Job 1 finishes, the files are stored as artifacts.
- These files can be saved for use in later stages or jobs.
-
Job 2: A later job (such as testing or deployment) retrieves the artifact files.
- This job can use the build output from Job 1 without needing to rebuild it.
-
Artifact Expiry: Optionally, the artifacts may expire after a certain time and be automatically cleaned up.
While this is a text description, if you need a more detailed diagram, I can provide a simpler flow or guide you to resources where you can see the actual visualization. Let me know if you'd like more help!