0

I'm trying to get an if statement run if env.someBool.toBoolean() returns null or true. However the toBoolean() causes it to throw if it's null.

java.lang.NullPointerException: Cannot invoke method toBoolean() on null object

I would say that null does not equal false, so should return true, but it throws before it can come to such a conclusion.

A colleague who works with Jira's groovy linked me to this as a possible way forward, but I can't see how to adapt it to Jenkinsfile env.xyz

Alistair Hardy
  • 397
  • 1
  • 4
  • 16

1 Answers1

0

As @dagett said, the Safe Navigation Operator did the trick.

Alistair Hardy
  • 397
  • 1
  • 4
  • 16