Pipeline Parameters
Learn the concepts, syntax options, parameter types, and scoping techniques required to define code-driven runtime inputs inside your Jenkinsfile.
What are Pipeline Parameters?
While Phase 2 introduced basic UI-configured job fields, **Pipeline Parameters** in a modern Declarative Jenkinsfile are defined explicitly as code. By declaring a dedicated parameters block at the root layer of your script, you instruct Jenkins to dynamically build its interactive user input dashboard directly from your source control asset.
Code-Driven Parameter Types
A standard declarative configuration supports several specific input types declared directly inside the root block structure:
- The `string` Parameter: A plain text text box ideal for supplying freeform tracking labels, target branch tags, or custom version metadata strings.
- The `choice` Parameter: An explicit multi-option dropdown list layout that prevents input typos by confining user selections to approved safety values.
- The `booleanParam` Parameter: A standard checkbox toggle switch used to pass clean true/false conditional statements to downstream code paths.
- The `text` Parameter: An expanded multi-line string input block reserved for passing longer configurations, scripts, or runtime release summary notes.
Key Concepts
First-Run Registration Lag
Understanding that when you commit a new `parameters` block to your repository, Jenkins must execute the pipeline at least once using default fallback parameters before the interactive dashboard UI updates on the server.
The `params` Object Scope
Learning to safely query user-supplied configuration values within your stage blocks by referencing the global read-only namespace wrapper using dot notation (e.g., `params.CHOICE_NAME`).
Practical Jenkins Example
The following declarative blueprint introduces native parameter declaration blocks along with programmatic evaluation syntax rules:
pipeline {
agent any
// 1. Defining input configurations natively as code
parameters {
string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Target code branch repository path.')
choice(name: 'TARGET_ENVIRONMENT', choices: ['Development', 'Staging', 'Production'], description: 'Target deployment infrastructure node.')
booleanParam(name: 'SKIP_CODE_LINTING', defaultValue: false, description: 'Check box to bypass checking validation stages.')
}
stages {
stage('Initialize Custom Runtime') {
steps {
// 2. Reading dynamic arguments using standard string interpolation mappings
echo "INFO: Initializing build workflows for branch: \${params.GIT_BRANCH}"
echo "INFO: Target staging server target assigned: \${params.TARGET_ENVIRONMENT}"
}
}
stage('Conditional Quality Controls') {
steps {
echo 'INFO: Analyzing step configurations against parameter rules...'
// Code conditions can evaluate these parameter values directly
}
}
}
}
Practice Exercise: Instantiate a Code-Defined Parameter Matrix
Step-by-Step Task Sequence:
- Open the script configuration code panel for an active test pipeline or spin up a new Pipeline item from your portal home screen.
- Copy-paste the complete practical declarative sample code provided in the example section above directly into your script block window and click Save.
- Click **Build Now** to start a baseline registration run. *Note: The first run uses your predefined default values because the interface dashboard hasn't parsed the file options yet.*
- Once the initial run iteration registers successfully, return to the job's main landing page to observe the **Build Now** link update to read **Build with Parameters**.
- Click **Build with Parameters**, tweak the string branch properties or change the environment selection options in the generated form, and click **Build** to verify your inputs inside the **Console Output**.
Summary
You have completed the Pipeline Parameters lesson. Continue through the syllabus to leverage these input choices to drive conditional execution criteria by exploring the Conditional Execution with when lesson.