Home > Enterprise >  Jenkins pipeline check if choice parameter has bee nset/exists
Jenkins pipeline check if choice parameter has bee nset/exists

Time:09-08

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?

CodePudding user response:

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

CodePudding user response:

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

  • Related