title: println in "call" method of "vars/foo.groovy" works, but not in method in class
body: <p>I'm iterating through building a Jenkins pipeline shared library, so my Jenkinsfile is a little cleaner.</p>
  
  <p>I'm using the following page for guidance: <a href="https://jenkins.io/doc/book/pipeline/shared-libraries/" rel="noreferrer">https://jenkins.io/doc/book/pipeline/shared-libraries/</a> .</p>
  
  <p>I first defined several methods in individual files, like "<code>vars/methodName.groovy</code>", with a "<code>call()</code>" method in the code.  This works ok, and I particularly note that "<code>println</code>" calls in these methods are seen in the Jenkins console output.</p>
  
  <p>I then decided I wanted to save some state between method calls, so I added a new file in "<code>vars</code>" named "<code>uslutils.groovy</code>" that begins like this (minus some required imports):</p>
  
  <pre><code>class uslutils implements Serializable {
  </code></pre>
  
  <p>I defined some "<code>with&lt;property&gt;</code>" methods that set a property and return this.</p>
  
  <p>I then wrote a "<code>public String toString()</code>" method in "<code>uslutils</code>" that looks something like this:</p>
  
  <pre><code>public String toString() {
      println "Inside uslutils.toString()."
      return "[currentBuild[${currentBuild}] mechIdCredentials[${mechIdCredentials}] " +
             "baseStashURL[${baseStashURL}] jobName[${jobName}] codeBranch[${codeBranch}] " +
             "buildURL[${buildURL}] pullRequestURL[${pullRequestURL}] qBotUserID[${qBotUserID}] " +
             "qBotPassword[${qBotPassword}]]"
  }
  </code></pre>
  
  <p>Then, inside my Jenkinsfile, after setting the uslutils properties, I added a line like this:</p>
  
  <pre><code>println "uslutils[${uslutils}]"
  </code></pre>
  
  <p>Then, I ran my job, and the curious thing that happened is that I didn't see the "uslutils" line, or the <code>Inside uslutils.toString()</code>. line.  However, I did modify the one functional method I've added so far to "uslutils" (besides the "with" methods), which returns a string value, and I just added an "x" to the value.  My Jenkinsfile was printing the result from that, and it did show the additional "x".</p>
  
  <p>Note that no errors occurred here, it just seemed to omit the <code>println</code> output from within the shared library class, and even stranger, omitted the output from the <code>println</code> call in the Jenkinsfile that was implicitly calling the <code>uslutils.toString()</code> method.  Note that the <code>println</code> calls in the original <code>call()</code> methods WERE seen in the console output.</p>
  
  <p>Any ideas what might be happening here?</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I now have the following lines in my Jenkinsfile (among others):</p>
  
  <pre><code>println "uslutils.qBotPassword[${uslutils.qBotPassword}]"
  println "uslutils[${uslutils}]"
  println "uslutils.toString()[${uslutils.toString()}]"
  </code></pre>
  
  <p>And to repeat, here is the "uslutils.toString()" method:</p>
  
  <pre><code>public String toString() {
      println "Inside uslutils.toString()."
      return "[currentBuild[${currentBuild}] mechIdCredentials[${mechIdCredentials}] " +
             "baseStashURL[${baseStashURL}] jobName[${jobName}] codeBranch[${codeBranch}] " +
             "codeURL[${codeURL}] buildURL[${buildURL}] pullRequestURL[${pullRequestURL}] qBotUserID[${qBotUserID}] " +
             "qBotPassword[${qBotPassword}]]"
  }
  </code></pre>
  
  <p>Here are corresponding lines of output from the build:</p>
  
  <pre><code>[Pipeline] echo
  uslutils.qBotPassword[...]
  [Pipeline] echo
  uslutils.toString()[[currentBuild[org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper@41fb2c94] mechIdCredentials[121447d5-0fe4-470d-b785-6ce88225ef01] baseStashURL[https://...] jobName[unified-service-layer-build-pipeline] codeBranch[master] codeURL[ssh://git@...] buildURL[http://...] pullRequestURL[] qBotUserID[...] qBotPassword[...]]
  </code></pre>
  
  <p>As you can see, the line attempting to <code>print "uslutils[${uslutils}]"</code> was simply ignored.  The line attempting to <code>print "uslutils.toString()[${uslutils.toString()}]"</code> did render, but also note that the <code>Inside uslutils.toString()</code>. did not render.</p>
  
  <p>I'm still looking for an explanation for this behavior, but perhaps this summarizes it more succinctly.</p>