Instead of manually selecting parameters through the GUI every time, we can define them directly in the pipeline code using a parameters block placed right after agent.
environment block.pipeline {
agent any
parameters {
string(name: "person", defaultValue: "Sandeep", description: "")
}
stages {
stage('Hello') {
steps {
sh 'echo "hi my name is $person"'
}
}
}
}
pipeline {
agent any
parameters {
booleanParam(name: "db", defaultValue: true, description: "")
}
stages {
stage('Hello') {
steps {
sh 'echo "hi this is boolean parameters"'
}
}
}
}
If defaultValue is true, the checkbox appears checked (enabled) on the Build with Parameters screen; false leaves it unchecked.
pipeline {
agent any
parameters {
choice(name: "file", choices: ["sandeep", "chikkala", "sandy", "bablu"], description: "")
}
stages {
stage('Choice Parameter') {
steps {
sh 'echo "touch $file"'
}
}
}
}
On "Build with Parameters" you get a dropdown to pick one of the listed choices, which then feeds into the shell command.
Hands-on live training, real projects, and placement support — become job-ready in DevOps.
Enroll in DevOps Training →