[JENKINS-17960] Simplify logic