title: Constructor not called in Jenkins Shared Libraries
body: <p>I am trying to develop shared libraries and has the following directory structure</p>
  
  <ul>
  <li>src/com/mycomapny
  
  <ul>
  <li>MyTest.groovy</li>
  </ul></li>
  <li>vars
  
  <ul>
  <li>test.groovy</li>
  </ul></li>
  <li>Jenkinsfile</li>
  </ul>
  
  <p>my <strong>Jenkinsfile</strong> calls only method available in the <strong>test.groovy</strong> with required input.  which imports MyTest and creates object and calls constructor and followed by the actual method that executes the functionality available in the <strong>MyTest.groovy</strong> file</p>
  
  <p>Here the constructor class never called from global vars/test.groovy </p>
  
  <p>I tried calling class and method from groovy it is working fine but when i am calling it from jenkinsfile it is not working. I don't know why i am not able to call constructor and what i am missing.</p>
  
  <p>I have placed <strong>@NonCPS</strong> on above test.groovy method but still it is not working. </p>
  
  <pre><code>//MyTest.groovy
  package com.mycompany
  
  class MyTest implements Serializable {
      public _notification
  
      MyTest(Closure content) {
          notification = [:]
          content.resolveStrategy = Closure.DELEGATE_FIRST
          content.delegate = notification
          content()
          println("Entered Constructor")
          this._notification = notification
      }
  
  }
  
  //test.groovy
  import com.mycopany.MyTest
  def notify(Closure content) {
      println("This is line i am getting in the output but nothing after that")
      MyTest tester = new MyTest(content)
      println(tester._notification.colorcode)
  } 
  
  //Jenkinsfile
  @library("MysharedLibrary@master") _
  pipeline{
      stages {
           stage {
               steps {
                   test.notify {
                        buildno = 12
                        jobname = "Mytest"
                        colorcode = "Blue"
                   }
               }
           }
      }
  }
  </code></pre>
  
  <p>here i just want to call constructor from jenkins file and print the value of input value in my vars/test.groovy.</p>
  
  <p>EDIT1:
  When I use @NonCPS above the method "def nofity" my build is getting successful but i am getting nothing except print statement in the first line in the notify method.</p>
  
  <p>If I don't use @NonCPS I am getting following Exception</p>
  
  <pre><code>Error when executing always post condition:
  com.cloudbees.groovy.cps.impl.CpsCallableInvocation
  
  hudson.remoting.ProxyException:com.cloudbees.groovy.cps.impl.CpsCallableInvocation
  Finished: FAILURE
  </code></pre>