title: How do you handle global variables in a declarative pipeline?
body: <p>Previously <a href="https://stackoverflow.com/questions/47684675/define-global-environment-variables-from-inside-a-stage">asked a question</a> about how to overwrite variables defined in an environment directive and it seems that's not possible.</p>
  
  <p>I want to set a variable in one stage and have it accessible to other stages.
  In a declarative pipeline it seems the only way to do this is in a script{} block.</p>
  
  <p>For example I need to set some vars after checkout. So at the end of the checkout stage I have a script{} block that sets those vars and they are accessible in other stages.</p>
  
  <p>This works, but it feels wrong. And for the sake of readability I'd much prefer to declare these variables at the top of the pipeline and have them overwritten. So that would mean having a "set variables" stage at the beginning with a script{} block that just defines vars- thats ugly.</p>
  
  <p>I'm pretty sure I'm missing an obvious feature here. Do declarative pipelines have a global variable feature or must I use script{} </p>