title: Is it possible to reuse code in a Jenkins declarative pipeline?
body: <p>I would like to reuse code between different Jenkins deployments. Is it possible to share, for example, both to staging and to production, such that the only differences are the environment variables?</p>
  <p>I imagine it could look something like this (although this obviously doesn't work):</p>
  <pre><code>pipeline {
      stage(&quot;Dev Deploy&quot;){
          environment {
              PROP1 = &quot;abc&quot;
          }
          deploy ()
      }
      stage(&quot;Prod Deploy&quot;){
          environment {
              PROP1 = &quot;xyz&quot;
          }
          deploy ()
      }
  }
  
  deploy = steps{
              sh &quot;./gradlew deploy -Pproperty1=${env.PROP1}&quot;
          }
  </code></pre>