What if you could run the same job many ways without rewriting a single line?
Why String, boolean, and choice parameters in Jenkins? - Purpose & Use Cases
Imagine you need to run a Jenkins job that asks your team for input like a name, a yes/no decision, or a choice from a list. Without parameters, you have to edit the job script every time to change these values.
Manually changing scripts is slow and risky. You might mistype values or forget to update something. It's like rewriting a letter every time you want to send it to a different friend instead of just filling in a form.
Using string, boolean, and choice parameters lets Jenkins ask for inputs before running a job. This makes your jobs flexible and safe. You just fill in the answers, and Jenkins uses them automatically.
def name = 'Alice' def deploy = false def env = 'dev' // Change these values in the script every time
parameters {
string(name: 'name', defaultValue: '', description: 'Enter your name')
booleanParam(name: 'deploy', defaultValue: false, description: 'Deploy now?')
choice(name: 'env', choices: ['dev', 'test', 'prod'], description: 'Select environment')
}You can run the same Jenkins job many ways without changing code, making automation easy and error-free.
A developer triggers a build and selects 'prod' environment and 'true' for deploy, all through a simple form, without touching the job script.
Manual input changes are slow and risky.
Parameters let Jenkins ask for inputs before running.
This makes jobs flexible, safe, and easy to reuse.