GitLab CI comparison in Jenkins - Time & Space Complexity
We want to understand how the time it takes to run Jenkins pipelines grows as we add more jobs or stages.
How does Jenkins handle more work compared to GitLab CI?
Analyze the time complexity of this Jenkins pipeline snippet:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}
This pipeline runs three stages sequentially: Build, Test, and Deploy.
Look at what repeats as the pipeline grows.
- Primary operation: Each stage runs one after another.
- How many times: Number of stages determines how many steps run.
As you add more stages, the total time grows roughly by how many stages you have.
| Input Size (n = stages) | Approx. Operations (steps run) |
|---|---|
| 3 | 3 steps |
| 10 | 10 steps |
| 100 | 100 steps |
Pattern observation: The time grows directly with the number of stages.
Time Complexity: O(n)
This means if you double the number of stages, the total time roughly doubles.
[X] Wrong: "Adding more stages won't affect total time because they run in parallel."
[OK] Correct: In Jenkins, stages run one after another by default, so more stages mean more total time.
Understanding how pipeline steps add up helps you design efficient CI/CD workflows and explain your choices clearly.
What if we changed the pipeline to run stages in parallel? How would the time complexity change?