How do parameters work in a Jenkins pipeline?

BeginnerConceptJenkins
Answer

The parameters directive adds a "Build with Parameters" form: string, booleanParam, choice, password, text. Values are available as params.NAME and as environment variables. On the first run of a branch the parameters are not yet registered, which is a known gotcha.

parameters {
  choice(name: 'ENV', choices: ['dev', 'staging', 'prod'], description: 'Target')
  booleanParam(name: 'RUN_E2E', defaultValue: true)
}
// usage: echo "Deploying to ${params.ENV}"
All CI/CD questions

More on Jenkins