
Module 3 Lesson 1: Hello World Pipeline
Your first automated build. Follow a step-by-step guide to creating, committing, and running your very first GitLab CI/CD pipeline.
Module 3 Lesson 1: Hello World Pipeline
It's time to stop talking and start building. In this lesson, we will create a "Minimal Viable Pipeline."
1. Prerequisites
- A GitLab account (GitLab.com is fine).
- A new, empty project.
2. Step 1: Create the file
In your project's root directory, create a new file named exactly .gitlab-ci.yml.
# Define our simple stages
stages:
- build
- test
# Our first job
say-hello:
stage: build
script:
- echo "Hello from GitLab CI!"
- date
# Our second job
run-test:
stage: test
script:
- echo "Running simulation..."
- exit 0 # 0 means success
3. Step 2: Commit and Push
Push this file to your main branch.
git add .gitlab-ci.yml
git commit -m "Add first pipeline"
git push origin main
4. Step 3: Watch it run
- Go to your GitLab project sidebar.
- Click Build -> Pipelines.
- You should see a new entry marked as Running.
- Click the status circle. You will see the pipeline graph.
- Click on the
say-hellojob to see the live console output from the Runner!
5. Troubleshooting the "Pending" State
If your pipeline stays in "Pending" for a long time:
- Reason: You might not have any runners available.
- Fix: Ensure you have verified your account with a credit card (GitLab requirement for shared runners) or install a specific runner on your computer.
Exercise: The Success Streak
- Modify your
run-testjob. Changeexit 0toexit 1. - Push the change.
- Watch the pipeline. Did it turn Red (Failed)?
- Check the logs of the failed job. What does GitLab say?
- Fix it back to
exit 0and verify it turns Green again. - Why is the "Live Log" the most important tool for a CI/CD engineer?
Summary
You have officially automated your first task. While this pipeline only prints "Hello," the same logic applies to compiling a complex Java app, building a Docker image, or deploying a global website.
Next Lesson: Protecting the secrets: Environments and Variables.