Why parameterized pipelines matter in Jenkins - Performance Analysis
We want to understand how the time it takes to run a Jenkins pipeline changes when we add parameters.
How does adding parameters affect the work Jenkins does each time?
Analyze the time complexity of the following Jenkins pipeline snippet.
pipeline {
agent any
parameters {
string(name: 'BRANCH', defaultValue: 'main', description: 'Git branch to build')
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests?')
}
stages {
stage('Build') {
steps {
echo "Building branch ${params.BRANCH}"
}
}
stage('Test') {
when {
expression { return params.RUN_TESTS }
}
steps {
echo 'Running tests'
}
}
}
}
This pipeline uses parameters to decide what branch to build and whether to run tests.
Look for repeated actions that depend on parameters.
- Primary operation: Running build and optionally tests based on parameters.
- How many times: Each pipeline run executes once, but steps inside may vary.
The pipeline runs once per trigger, but the work inside can change with parameters.
| Input Size (n) | Approx. Operations |
|---|---|
| 1 parameter | 1 build run, fixed steps |
| 2 parameters | 1 build run, steps vary by parameters |
| 5 parameters | 1 build run, more conditional steps |
Pattern observation: The number of steps can grow with parameters, but the pipeline still runs once per trigger.
Time Complexity: O(1)
This means the pipeline runs once per trigger, and parameters only change what happens inside, not how many times it runs.
[X] Wrong: "Adding more parameters makes the pipeline run slower many times over."
[OK] Correct: Parameters change what steps run inside one pipeline execution, but they do not multiply how many times the pipeline runs.
Understanding how parameters affect pipeline execution helps you design flexible builds without worrying about unnecessary slowdowns.
"What if we added a loop inside the pipeline that runs steps for each parameter value? How would the time complexity change?"