0
0
Jenkinsdevops~5 mins

Parameters block declaration in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the parameters block in a Jenkins pipeline?
The parameters block lets you define inputs that users can provide when starting a Jenkins job. These inputs can control how the job runs.
Click to reveal answer
beginner
Name two common parameter types you can declare inside the parameters block.
Two common parameter types are string for text input and booleanParam for true/false choices.
Click to reveal answer
beginner
How do you declare a string parameter named BRANCH with a default value of main?
Use string(name: 'BRANCH', defaultValue: 'main', description: 'Git branch to build') inside the parameters block.
Click to reveal answer
beginner
What happens if you run a Jenkins pipeline with a parameters block but do not provide any input values?
Jenkins uses the default values defined in the parameters block for the job run.
Click to reveal answer
beginner
Show a simple example of a parameters block with a string and a boolean parameter.
parameters { string(name: 'ENV', defaultValue: 'dev', description: 'Environment') booleanParam(name: 'DEBUG', defaultValue: false, description: 'Enable debug mode') }
Click to reveal answer
What is the correct syntax to declare a boolean parameter named RUN_TESTS with default true?
Abool(name: 'RUN_TESTS', default: true)
BparamBoolean('RUN_TESTS', true)
Cboolean(name: 'RUN_TESTS', defaultValue: true)
DbooleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests?')
Where do you place the parameters block in a Jenkins declarative pipeline?
AOutside the <code>pipeline</code> block
BInside a <code>stage</code> block
CInside the <code>pipeline</code> block but outside <code>stages</code>
DInside the <code>steps</code> block
What type of parameter would you use to let users pick from a list of options?
Achoice
Bstring
CbooleanParam
Dtext
If you want to ask users for a multi-line text input, which parameter type should you use?
Astring
Btext
CbooleanParam
Dchoice
What happens if you omit the parameters block in a Jenkins pipeline?
AThe pipeline runs without asking for inputs
BThe pipeline asks for inputs anyway
CJenkins throws an error
DThe pipeline will not run
Explain how to declare and use parameters in a Jenkins declarative pipeline.
Think about where the parameters block goes and how users provide inputs.
You got /4 concepts.
    Describe the difference between string and choice parameters in Jenkins.
    Consider how users select or enter values.
    You got /3 concepts.