title: Check if property exists Groovy
body: <p>I am using multi-branch plugin in Jenkins and polling my git repo to see if there are any changes. My problem is that when it polls, my $GIT_BRANCH_NAME variable doesn't exist and the build fails. </p>
  
  <pre><code>groovy.lang.MissingPropertyException: No such property: GIT_BRANCH_NAME for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)
  </code></pre>
  
  <p>I tried checking for</p>
  
  <pre><code>if (!bindings.hasProperty(GIT_BRANCH_NAME)){
  echo "Why is this not working"
  env.GIT_BRANCH_NAME = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code> if (!project.hasProperty(GIT_BRANCH_NAME)){
      echo "Why is this not working"
      env.GIT_BRANCH_NAME = sh(script: "git rev-parse HEAD", returnStdout: true).trim()
      }
  </code></pre>
  
  <p>It doesn't work though. Any help is appreciated</p>