title: How to return a value from a function in Jenkins pipeline for an 'allOf'
body: <p>We have a Jenkins pipeline setup using the Jenkinsfile to define what needs to be done for the different builds.</p>
  
  <p>In a lot of our stages, we have some work that needs to be done when we're going to be doing a release, but can be skipped if a release isn't going to be done.</p>
  
  <p>Currently we have this code:</p>
  
  <pre><code>when {
    allOf {
      anyOf {
        branch 'master';
        branch 'develop';
      }
      expression {
        return params.DBTESTS
      }
    }
  }
  </code></pre>
  
  <p>repeated across all of the stages that can be skipped.</p>
  
  <p>How would I convert that into a function, so that the logic is in one place similar to something like this:</p>
  
  <pre><code>def isReleasePlanned() {
     return  allOf {
        anyOf {
           branch 'master';
           branch 'develop';
        }
        expression {
          return params.DBTESTS
        }
      }
    }
  }
  </code></pre>
  
  <p>and then used like this:</p>
  
  <pre><code>when {
    isReleasePlanned()
  }
  </code></pre>
  
  <p>In each of the stages. Currently that is a syntax error when Jenkins tries to read the Jenkinsfile.</p>