0
0
Jenkinsdevops~10 mins

Parameters block declaration in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Parameters block declaration
Start Jenkins Pipeline
Declare parameters block
Define parameter types
Parameters available for input
Pipeline uses parameter values
Pipeline runs with inputs
The pipeline starts, declares a parameters block with input types, waits for user input, then runs using those values.
Execution Sample
Jenkins
pipeline {
  agent any
  parameters {
    string(name: 'GREETING', defaultValue: 'Hello', description: 'Say something')
  }
  stages {
    stage('Example') {
      steps {
        echo params.GREETING
      }
    }
  }
}
This Jenkins pipeline declares a string parameter GREETING and prints its value during the build.
Process Table
StepActionParameter Block StateParameter ValuePipeline Output
1Start pipelineNo parameters declared yetN/AN/A
2Declare parameters blockParameters block created with GREETING stringDefault: 'Hello'N/A
3Wait for user inputParameters block activeUser inputs 'Hi there'N/A
4Start stage 'Example'Parameters block activeGREETING='Hi there'N/A
5Execute echo stepParameters block activeGREETING='Hi there'Hi there
6Pipeline endsParameters block usedGREETING='Hi there'Hi there
💡 Pipeline ends after executing all stages using the provided parameter value.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 5Final
params.GREETINGundefined'Hello' (default)'Hi there' (user input)'Hi there''Hi there'
Key Moments - 3 Insights
Why does the pipeline wait after declaring the parameters block?
Because the parameters block defines inputs that Jenkins must collect before running the pipeline, as shown in step 3 of the execution_table.
What happens if the user does not provide input for the parameter?
The pipeline uses the default value defined in the parameters block, like 'Hello' in step 2 of the execution_table.
How does the pipeline access the parameter value inside the stages?
It uses the 'params' object with the parameter name, e.g., params.GREETING, as shown in step 5 where echo prints the value.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the parameter value at Step 3?
Aundefined
B'Hello' (default)
C'Hi there' (user input)
DN/A
💡 Hint
Check the 'Parameter Value' column at Step 3 in the execution_table.
At which step does the pipeline output the parameter value?
AStep 5
BStep 4
CStep 2
DStep 6
💡 Hint
Look at the 'Pipeline Output' column in the execution_table.
If the user did not input a value, what would params.GREETING be after Step 3?
A'Hi there'
B'Hello'
Cundefined
Dnull
💡 Hint
Refer to the default value in the 'Parameter Block State' at Step 2.
Concept Snapshot
Jenkins parameters block syntax:
parameters {
  string(name: 'PARAM', defaultValue: 'value', description: 'desc')
  booleanParam(name: 'FLAG', defaultValue: true, description: 'desc')
}
Parameters pause pipeline for input.
Access values via params.PARAM.
Defaults used if no input given.
Full Transcript
This visual execution shows how a Jenkins pipeline declares a parameters block with a string parameter named GREETING. The pipeline starts without parameters, then declares the parameters block with a default value 'Hello'. Jenkins waits for user input; if the user inputs 'Hi there', that value is stored. The pipeline then runs the Example stage, where it accesses params.GREETING and echoes the value. The pipeline ends after printing the parameter. Variables track the parameter value changes from undefined to default to user input. Key moments clarify why Jenkins waits for input, how defaults work, and how to access parameters in the pipeline. The quiz tests understanding of parameter values at different steps and default behavior.