Challenge - 5 Problems
Parameters Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Jenkins pipeline snippet?
Consider this Jenkins pipeline snippet with a parameters block. What will be the value of the parameter
DEPLOY_ENV when the pipeline starts?Jenkins
pipeline {
agent any
parameters {
string(name: 'DEPLOY_ENV', defaultValue: 'staging', description: 'Deployment environment')
}
stages {
stage('Print') {
steps {
echo "Deploying to ${params.DEPLOY_ENV}"
}
}
}
}Attempts:
2 left
💡 Hint
Look at the defaultValue set in the string parameter.
✗ Incorrect
The parameter DEPLOY_ENV is declared with a default value 'staging'. If the user does not override it, the pipeline uses 'staging'.
❓ Configuration
intermediate2:00remaining
Which parameters block correctly declares a boolean parameter named 'RUN_TESTS' with default true?
Select the correct Jenkins pipeline parameters block snippet that declares a boolean parameter
RUN_TESTS with a default value of true.Attempts:
2 left
💡 Hint
Check the exact method name and parameter names for boolean parameters in Jenkins.
✗ Incorrect
The correct syntax uses booleanParam with named parameters: name, defaultValue, and description.
❓ Troubleshoot
advanced2:00remaining
Why does this parameters block cause a syntax error?
Identify the reason for the syntax error in this Jenkins pipeline parameters block snippet.
Jenkins
parameters {
choice(name: 'ENV', choices: 'dev\nstaging\nprod', description: 'Select environment')
string(name: 'VERSION', defaultValue: '1.0')
}Attempts:
2 left
💡 Hint
Look at the type expected for the choices argument in choice parameter.
✗ Incorrect
The choices argument must be a list of strings or a single string with newline-separated options. Here it is a single string with escaped newlines, which is valid. But in Jenkins pipeline syntax, the choices parameter expects a single string with literal newlines, not escaped ones.
🔀 Workflow
advanced2:00remaining
In which stage does the parameter get evaluated in this Jenkins pipeline?
Given this Jenkins pipeline, when is the parameter
BUILD_TYPE evaluated and available for use?Jenkins
pipeline {
agent any
parameters {
choice(name: 'BUILD_TYPE', choices: ['debug', 'release'], description: 'Build type')
}
stages {
stage('Build') {
steps {
echo "Building ${params.BUILD_TYPE}"
}
}
}
}Attempts:
2 left
💡 Hint
Parameters are used to configure the pipeline before it runs.
✗ Incorrect
Parameters are evaluated at the start of the pipeline run and are available throughout all stages.
✅ Best Practice
expert3:00remaining
What is the recommended way to declare multiple parameters of different types in Jenkins pipeline?
Choose the best parameters block declaration that includes a string, boolean, and choice parameter correctly.
Attempts:
2 left
💡 Hint
Check the exact parameter method names and argument names for each type.
✗ Incorrect
Option B uses the correct method names and argument names for string, booleanParam, and choice parameters with proper descriptions and default values.