Initial Pipeline Configuration
Here’s a basic GitLab CI configuration defining three jobs:Relying on fixed
sleep intervals can lead to fragile pipelines. Instead, use proper job dependencies and artifacts to synchronize stages.Job Breakdown
| Job Name | Stage | Purpose |
|---|---|---|
| build_job_1 | build | Installs cowsay and generates dragon.txt |
| test_job_2 | test | Searches for “dragon” in the generated file |
| deploy_job_3 | deploy | Displays ASCII art and prints a deploy message |
- build_job_1 installs the
cowsaygem, pauses for 30 seconds, then writes ASCII art intodragon.txt. - test_job_2 pauses for 10 seconds before verifying the file contains the keyword “dragon.”
- deploy_job_3 outputs the contents of
dragon.txtand echoes a deploy message.
By default, GitLab CI jobs run in parallel on separate runners and do not share the same workspace.
Observed Failures
Because test_job_2 and deploy_job_3 often start before build_job_1 finishes, they encounter missing files:Why Jobs Fail
- Each job runs on a separate runner with its own workspace.
- There’s no file sharing by default.
- The execution order is not guaranteed without explicit dependencies.
Next Steps
In the next section, we’ll introduce theneeds keyword and artifacts settings to:
- Ensure build_job_1 completes before test_job_2.
- Share
dragon.txtas an artifact for downstream jobs. - Execute deploy_job_3 only after the test stage passes.