0
0
Gitdevops~10 mins

GitLab CI basics - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - GitLab CI basics
Push code to GitLab repo
GitLab detects push event
GitLab CI reads .gitlab-ci.yml
Pipeline starts: jobs run in stages
Jobs execute scripts on runners
Jobs report success or failure
Pipeline finishes with overall status
This flow shows how pushing code triggers GitLab CI to run jobs defined in the .gitlab-ci.yml file, executing them step-by-step and reporting results.
Execution Sample
Git
stages:
  - build
  - test

build_job:
  stage: build
  script:
    - echo "Building..."
test_job:
  stage: test
  script:
    - echo "Testing..."
This simple GitLab CI config defines two stages: build and test, each with one job that prints a message.
Process Table
StepActionJobStageScript RunJob StatusPipeline Status
1Push code to repo----pending
2GitLab detects push----pending
3Start pipeline----running
4Run build_jobbuild_jobbuildecho "Building..."successrunning
5Run test_jobtest_jobtestecho "Testing..."successsuccess
💡 All jobs completed successfully, pipeline status is success.
Status Tracker
VariableStartAfter Step 4After Step 5Final
Pipeline Statuspendingrunningsuccesssuccess
build_job Statusnot startedsuccesssuccesssuccess
test_job Statusnot startednot startedsuccesssuccess
Key Moments - 3 Insights
Why does the pipeline status change from 'pending' to 'running' before jobs start?
The pipeline status changes to 'running' as soon as GitLab starts executing jobs (see step 3 in execution_table). This means the pipeline is active even if no job has finished yet.
What happens if a job fails? Does the pipeline continue?
If a job fails, the pipeline status becomes 'failed' and subsequent jobs in later stages do not run. This is shown by the job status and pipeline status columns in the execution_table.
Why do jobs run in the order of stages?
Jobs run stage by stage to ensure dependencies. In the example, 'build' stage runs before 'test' stage (see 'Stage' column in execution_table). This order is defined in the 'stages' list in the config.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the pipeline status after step 4?
Asuccess
Brunning
Cpending
Dfailed
💡 Hint
Check the 'Pipeline Status' column at step 4 in the execution_table.
At which step does the 'test_job' start running?
AStep 5
BStep 4
CStep 3
DStep 2
💡 Hint
Look at the 'Job' and 'Step' columns in the execution_table to find when 'test_job' runs.
If the 'build_job' fails, what will happen to the pipeline status?
AIt will remain 'pending'
BIt will become 'success'
CIt will become 'failed'
DIt will skip to 'test' stage
💡 Hint
Refer to the key_moments explanation about job failure impact on pipeline status.
Concept Snapshot
GitLab CI basics:
- Push code triggers pipeline
- .gitlab-ci.yml defines stages and jobs
- Jobs run in stage order
- Each job runs scripts on runners
- Pipeline status reflects job results
- Failure stops later jobs
Full Transcript
GitLab CI basics start when you push code to a GitLab repository. GitLab detects this push and reads the .gitlab-ci.yml file to know what jobs to run. The pipeline starts and jobs run in the order of stages defined. Each job executes its script on a runner and reports success or failure. The pipeline status updates accordingly and finishes when all jobs complete or a failure occurs. This visual trace shows the pipeline moving from pending to running, then success after all jobs finish.