Build Parameters

parameters makes Build Now into Build with Parameters; values arrive as params.NAME in Groovy and as environment variables in steps. Types are string, text, booleanParam, choice and password:

decl-params: three parameters for a deployment jobGroovy
pipeline {
  agent { label 'linux' }
  parameters {
    choice(name: 'TARGET', choices: ['staging', 'production'], description: 'Where to deploy')
    string(name: 'BOOK_ID', defaultValue: '3', description: 'Book to smoke-test')
    booleanParam(name: 'DRY_RUN', defaultValue: true, description: 'Print, do not deploy')
  }
  stages {
    stage('Show') {
      steps {
        echo "TARGET=${params.TARGET} BOOK_ID=${params.BOOK_ID} DRY_RUN=${params.DRY_RUN}"
        sh 'echo "as environment variables too: $TARGET"'
      }
    }
  }
}

Jenkins 8,793 learns the definitions only by running the Jenkinsfile, so a new job is not parameterized yet:

decl-params before and during its first buildGroovy
J=http://localhost:32080; AUTH="admin:$JENKINS_TOKEN"
curl -s -u "$AUTH" -X POST "$J/job/decl-params/buildWithParameters?TARGET=production" \
  | grep -o 'Error 400[^<]*'
curl -s -u "$AUTH" -X POST $J/job/decl-params/build; sleep 15
curl -s -u "$AUTH" $J/job/decl-params/1/consoleText | grep -E '^(TARGET|as env)'
Output
Error 400 decl-params is not parameterized
TARGET=staging BOOK_ID=3 DRY_RUN=true
as environment variables too:

Build 1 got the defaults through params, but $TARGET was empty in the shell: read parameters through params. Build 2, run with TARGET=production&BOOK_ID=5&DRY_RUN=false, printed both correctly. New branches of a multibranch job hit the same trap, and rewriting a job's config.xml drops the definitions until the next run. Use credentials, not password parameters, for secrets.