0
0
Jenkinsdevops~10 mins

String, boolean, and choice parameters in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - String, boolean, and choice parameters
Start Job Configuration
Define Parameters
String
User Inputs Values
Job Runs Using Parameters
End
The flow shows defining three parameter types, user inputs values, then the job runs using those values.
Execution Sample
Jenkins
pipeline {
  agent any
  parameters {
    string(name: 'GREETING', defaultValue: 'Hello', description: 'Say hi')
    booleanParam(name: 'SHOUT', defaultValue: false, description: 'Uppercase?')
    choice(name: 'LANG', choices: ['English', 'Spanish'], description: 'Language')
  }
  stages {
    stage('Example') {
      steps {
        script {
          def msg = params.GREETING
          if (params.SHOUT) {
            msg = msg.toUpperCase()
          }
          echo "Message: ${msg} in ${params.LANG}"
        }
      }
    }
  }
}
Defines string, boolean, and choice parameters; then prints a message using them.
Process Table
StepParameter TypeInput ValueActionOutput
1String'Hello'Assign to msgmsg = 'Hello'
2BooleanfalseCheck SHOUTNo change to msg
3Choice'English'Select languageLANG = 'English'
4Print-Echo messageMessage: Hello in English
5String'Hi there'Assign to msgmsg = 'Hi there'
6BooleantrueCheck SHOUTmsg = 'HI THERE'
7Choice'Spanish'Select languageLANG = 'Spanish'
8Print-Echo messageMessage: HI THERE in Spanish
9---Job ends
💡 All parameters processed and message printed; job completes.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7After Step 8Final
msgundefined'Hello''Hello''Hello''Hello''Hi there''HI THERE''HI THERE''HI THERE''HI THERE'
SHOUTundefinedfalsefalsefalsefalsetruetruetruetruetrue
LANGundefinedundefined'English''English''English'undefinedundefined'Spanish''Spanish''Spanish'
Key Moments - 3 Insights
Why does the message change to uppercase only when SHOUT is true?
Because in the execution table at step 6, when SHOUT is true, the code converts msg to uppercase. When false (step 2), msg stays the same.
How does the choice parameter LANG affect the output?
LANG selects the language string used in the output message. Steps 3 and 7 show LANG changing, which changes the printed message accordingly.
What happens if the user does not provide input for the string parameter?
The default value 'Hello' is used as shown at step 1, so the job still runs with that default.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of msg after step 6?
A'Hi there'
B'HI THERE'
C'Hello'
Dundefined
💡 Hint
Check the 'Action' and 'Output' columns at step 6 where SHOUT is true and msg is uppercased.
At which step does the choice parameter LANG change to 'Spanish'?
AStep 7
BStep 2
CStep 3
DStep 5
💡 Hint
Look at the 'Input Value' and 'Action' columns for LANG changes in the execution table.
If SHOUT was always false, how would the output at step 8 change?
AMessage would be uppercase
BMessage would be empty
CMessage would remain as 'Hi there'
DJob would fail
💡 Hint
Refer to variable_tracker for msg values when SHOUT is false and how it affects output.
Concept Snapshot
Jenkins parameters let users input values before a job runs.
String parameters accept text input.
Boolean parameters are true/false switches.
Choice parameters let users pick from a list.
Use params.PARAM_NAME to access values in pipeline.
Defaults apply if user input is missing.
Full Transcript
This visual execution shows how Jenkins jobs use string, boolean, and choice parameters. First, parameters are defined with defaults. When the job runs, users can input values or accept defaults. The string parameter sets a message text. The boolean parameter controls if the message is uppercased. The choice parameter selects a language. The execution table traces each step: assigning values, checking conditions, and printing the final message. Variable tracking shows how msg, SHOUT, and LANG change over time. Key moments clarify why uppercase happens only when SHOUT is true, how choice affects output, and the role of defaults. The quiz tests understanding of variable states and parameter effects. This helps beginners see how parameters control job behavior visually and step-by-step.