Complete the code to define a string parameter named 'ENV' in a Jenkins pipeline.
parameters {
string(name: '[1]', defaultValue: 'dev', description: 'Environment')
}The parameter name must exactly match 'ENV' to be used consistently in the pipeline.
Complete the code to access the parameter 'ENV' inside the Jenkins pipeline script.
pipeline {
agent any
stages {
stage('Build') {
steps {
echo "Building for environment: [1]"
}
}
}
}In Jenkins pipelines, parameters are accessed using the 'params' object, e.g., params.ENV.
Fix the error in the parameter definition to correctly define a boolean parameter named 'RUN_TESTS'.
parameters {
booleanParam(name: '[1]', defaultValue: true, description: 'Run tests')
}Parameter names are case-sensitive and usually uppercase with underscores for clarity and consistency.
Fill both blanks to define a choice parameter named 'DEPLOY_ENV' with options 'dev', 'staging', and 'prod'.
parameters {
choice(name: '[1]', choices: [2], description: 'Select deployment environment')
}The parameter name should be 'DEPLOY_ENV' and choices must be a list of strings in the desired order.
Fill all three blanks to create a pipeline that uses a string parameter 'VERSION', checks if it is not empty, and echoes the version.
pipeline {
agent any
parameters {
string(name: '[1]', defaultValue: '', description: 'Version to build')
}
stages {
stage('Check Version') {
steps {
script {
if (params.[2] [3] '') {
echo "Building version: ${params.VERSION}"
} else {
error 'Version parameter is empty!'
}
}
}
}
}
}The parameter name is 'VERSION'. To check if it is not empty, use 'params.VERSION != '''.