What is the main purpose of using parameterized builds in Jenkins?
Think about how you can make a build flexible by asking for input before it starts.
Parameterized builds let users provide input values when starting a build, so the build can behave differently based on those inputs.
Given a Jenkins pipeline with a string parameter ENV defaulting to dev, what will be the output of the following snippet if the build is triggered with ENV=prod?
pipeline {
agent any
parameters {
string(name: 'ENV', defaultValue: 'dev', description: 'Environment')
}
stages {
stage('Print Env') {
steps {
echo "Deploying to ${params.ENV} environment"
}
}
}
}Remember that parameters override default values when provided at build time.
The parameter ENV is set to prod at build time, so the echo prints that value.
Which of the following Jenkins pipeline snippets correctly defines a boolean parameter named RUN_TESTS with a default value of true?
Check the exact syntax for boolean parameters in Jenkins declarative pipeline.
The correct syntax uses booleanParam to define a boolean parameter in Jenkins pipeline.
A Jenkins job is configured with a string parameter VERSION. When triggered manually, the build fails with the error groovy.lang.MissingPropertyException: No such property: VERSION. What is the most likely cause?
Think about how Jenkins exposes parameters to the pipeline script.
If the parameter is not declared in the pipeline, Jenkins does not create the variable, causing the error.
You want to create a Jenkins pipeline that deploys to different environments based on a parameter DEPLOY_ENV which can be dev, staging, or prod. Which pipeline snippet correctly implements this conditional deployment?
pipeline {
agent any
parameters {
choice(name: 'DEPLOY_ENV', choices: ['dev', 'staging', 'prod'], description: 'Select environment')
}
stages {
stage('Deploy') {
steps {
script {
// Fill in conditional deployment here
}
}
}
}
}Use Groovy script inside the script block to handle conditions.
Option C uses standard Groovy if-else statements inside the script block, which is the correct way to handle parameter-based conditions in Jenkins pipeline.