0
0
Jenkinsdevops~10 mins

Dynamic parameter values in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a dynamic choice parameter in Jenkins pipeline.

Jenkins
properties([parameters([choice(name: 'ENV', choices: [1], description: 'Select environment')])])
Drag options to blanks, or click blank then click option'
A"dev, staging, prod"
B['dev', 'staging', 'prod']
C["dev", "staging", "prod"]
D"dev\nstaging\nprod"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list instead of a newline-separated string.
Using commas inside the string instead of newlines.
2fill in blank
medium

Complete the code to set a dynamic string parameter with a default value.

Jenkins
properties([parameters([string(name: 'VERSION', defaultValue: [1], description: 'Enter version')])])
Drag options to blanks, or click blank then click option'
A"1.0.0"
B1.0.0
C'1.0.0'
Dversion
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the version string.
Using single quotes which may cause syntax issues.
3fill in blank
hard

Fix the error in the code to dynamically generate choices from a Groovy list.

Jenkins
def envs = ['dev', 'qa', 'prod']
properties([parameters([choice(name: 'ENV', choices: [1], description: 'Choose environment')])])
Drag options to blanks, or click blank then click option'
Aenvs
Benvs.join('\n')
Cenvs.toString()
Denvs.join(',')
Attempts:
3 left
💡 Hint
Common Mistakes
Joining with commas instead of newlines.
Passing the list directly without conversion.
4fill in blank
hard

Fill both blanks to create a dynamic boolean parameter with a default value.

Jenkins
properties([parameters([booleanParam(name: [1], defaultValue: [2], description: 'Enable feature')])])
Drag options to blanks, or click blank then click option'
A"ENABLE_FEATURE"
Btrue
Cfalse
DENABLE_FEATURE
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the parameter name.
Using string 'true' instead of boolean true.
5fill in blank
hard

Fill all three blanks to define a dynamic choice parameter with options generated from a list and a description.

Jenkins
def branches = ['main', 'develop', 'feature']
properties([parameters([choice(name: [1], choices: [2], description: [3])])])
Drag options to blanks, or click blank then click option'
A"BRANCH"
Bbranches.join('\n')
C"Select the git branch to build"
Dbranches.toString()
Attempts:
3 left
💡 Hint
Common Mistakes
Using toString() for choices instead of joining with newlines.
Not quoting name or description.