title: How to overwrite global variable in jenkins groovy
body: <p>I was working on a jenkins groovy script. I have defined one global variable at the start of the script, That is being used all over the groovy.
  Users using that groovy can modify the value for global variable as per their requirement.</p>
  <p>Now the issue is that I want to set a default value to the global variable in case a user left the global variable blank, How can I achieve this scenerio in Groovy ?</p>
  <p>Thanks in advance.
  below is how my groovy looks like</p>
  <pre><code>String var1 = &quot; &quot;
  String var2 = &quot; &quot;
  
  pipeline {
    agent any
    stages {
  
      stage('Stage 1') {
        steps {
          script {
            if(var1 == &quot; &quot;) {
                var1 = &lt;default value&gt;
            }
          }
        }
      }
  
      stage('Stage 2') {
        steps {
          script {
            docker login &lt;here i want to use default var1&gt;
          }
        }
      }
  
    }
  }
  </code></pre>