fraserc182
fraserc182

Reputation: 313

Jenkins pipeline check if choice parameter has bee nset/exists

At the beginning of my pipeline a choice is made:

  parameters {
    choice(
      name: 'jobRunMode',
      choices: ['Create/Update','Delete'],
      description: 'Job run mode')    

  }

However, when this build is triggered for the first time the user does not make a choice, thus this variable does not exist or is empty.

How do I check if this parameter exists or not?

Upvotes: 0

Views: 846

Answers (2)

himneh
himneh

Reputation: 116

Instead of checking, just add Default Value to this param so it always exists xD.

Upvotes: -1

Matthew Schuchard
Matthew Schuchard

Reputation: 28774

A straightforward conditional for object value assignment would be: params.jobRunMode == null.

Upvotes: 2

Related Questions