How do I use Jenkins Pipeline properties step?

Solution 1:

Using properties with explicit method syntax will work, i.e.:
properties( [ ... ] ) rather than properties [ ... ]

Alternatively, it will work without if you specify the parameter name, e.g.:

properties properties: [ ... ]

For example defining three properties is as easy as :

properties([
  parameters([
    string(name: 'submodule', defaultValue: ''),
    string(name: 'submodule_branch', defaultValue: ''),
    string(name: 'commit_sha', defaultValue: ''),
  ])
])

/* Accessible then with : params.submodule, params.submodule_branch...  */

Solution 2:

Multiple choice in Jenkins scripted pipeline

properties([
  parameters([
        choice(choices: 'sprint_6\nsprint_7\nsprint_8\nSprint_9', description: 'Select branch to Build', name: 'Branch'),
        choice(choices: 'No\nYes', , name: 'choice2'),
        choice(choices: 'No\nYes', name: 'choice3')
  ])
])