title: Jenkins and Groovy and Regex
body: <p>I am very new to using groovy.  Especially when it comes to Jenkins+Groovy+Pipelines.</p>
  <p>I have a string variable that can change from time to time and want to apply a regex to accomodate the 2 or 3 possible results the string may return.</p>
  <p>In my groovy code I have:</p>
  <pre><code>r = &quot;Some text that will always end in either running, stopped, starting.&quot;
  def regex = ~/(.*)running(.*)/
  assert regex.matches(r)
  </code></pre>
  <p>But I receive an error in the jenkins output:</p>
  <blockquote>
  <p>hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.regex.Pattern.matches() is applicable for argument types: (java.lang.String)</p>
  </blockquote>
  <p>UPDATE:
  I was able to create a pretty nifty jenking groovy while loop in a pipeline job i am creating to wait for a remote process using the regex info here and a tip in a different post (<a href="https://stackoverflow.com/q/8188641/1741264">How do I iterate over all bytes in an inputStream using Groovy, given that it lacks a do-while statement?</a>).</p>
  <pre><code>            while({
                  def r = sh returnStdout: true, script: 'ssh &quot;Insert your remote ssh command that returns text'
                  println &quot;Process still running.  Waiting on Stop&quot;
                  println &quot;Status returned: $r&quot;
                  r =~ /running|starting|partial/
              }());
  </code></pre>