>_ IzzyLab

Hands-on task

This task is step 8 of the course “CI/CD: pipelines and docker compose”

Pipeline with artifacts

medium~15 min

The project app (cloned to /root/app, the web sign-in is on the GitLab tab) has a build script build.sh: it puts its result into the out/ directory. There's no CI, and a runner is already connected.

Write a .gitlab-ci.yml with a build job in the build stage: it runs ./build.sh and keeps the out/ directory as artifacts. Push to main and get a green pipeline.

Then open the build job in GitLab and download its artifact: it must contain out/release.txt.

What you'll practise:
  • gitlab ci
  • artifacts
  • yaml
  • stages
  • pipeline

Topic breakdown

In GitLab CI a job is a top-level key of .gitlab-ci.yml (unlike the nested jobs in GitHub Actions), tied to a stage via stage and containing a list of commands in script. Artifacts are a mechanism for passing files between stages: paths declared in the artifacts block are, after a successful job, packed up and automatically forwarded to jobs of the following stages. The main principle is that a path in artifacts.paths must actually exist by the end of the job (the script must create it) and is considered relative to the job's working directory, not as an absolute /root/....

What's checked

  1. .gitlab-ci.yml is in main
  2. Latest pipeline on main is green
  3. The build job in the build stage passed
  4. The build artifact has out/release.txt

What it looks like