VERSION with default value 1.0VERSION parameter in a shell build stepVERSION value at the endVERSION with default value 1.0VERSION parameter in a shell build stepVERSION value at the endVERSION parameterVERSION with the default value 1.0. Use the parameters block to do this.Use the parameters block inside the pipeline and add a string parameter with the name VERSION.
VERSION parameterBuild stage's steps block, add a shell command that echoes Building version: ${VERSION} using the Jenkins parameter VERSION.Use the sh step with a command that prints the VERSION parameter value.
VERSIONPrint Version after the Build stage. Inside its steps block, add a shell command that prints Selected version is: ${VERSION}.Add a new stage block with the name Print Version and inside it add a sh step to print the version.
Building version: 1.0 and Selected version is: 1.0 when using the default parameter.Run the pipeline with default parameters and check the console output for the expected lines.
What is the main purpose of parameterized builds in Jenkins?
Which of the following is the correct syntax to define a string parameter named ENV in a Jenkins pipeline?
parameters {
?
}string(name: '', defaultValue: '', description: '') inside parameters block.Given this Jenkins pipeline snippet, what will be printed if the build is started with parameter BRANCH=feature?
pipeline {
agent any
parameters {
string(name: 'BRANCH', defaultValue: 'main', description: 'Git branch')
}
stages {
stage('Print Branch') {
steps {
echo "Building branch: ${params.BRANCH}"
}
}
}
}BRANCH has default 'main' but can be overridden at build start.params.BRANCH is 'feature'.Identify the error in this Jenkins pipeline snippet that defines a boolean parameter:
pipeline {
agent any
parameters {
booleanParam(name: 'DEPLOY', default: true, description: 'Deploy after build?')
}
stages {
stage('Check Deploy') {
steps {
script {
if (params.DEPLOY) {
echo 'Deploying...'
} else {
echo 'Skipping deploy'
}
}
}
}
}
}booleanParam(name: '', defaultValue: true/false, description: '').default instead of defaultValue, causing syntax error.You want to create a Jenkins pipeline that asks for two parameters: a choice of ENV with options dev, qa, prod, and a boolean RUN_TESTS. The pipeline should print the selected environment and whether tests will run. Which snippet correctly defines these parameters and uses them in the Print Info stage?
choices as a list, boolean parameter uses booleanParam with defaultValue.params.ENV and params.RUN_TESTS inside echo.Pass the test and this pattern moves unknown