title: Groovy Postbuild in Jenkins, parsing the log for strings and counting them
body: <p>I am new to Groovy and am trying to set up a postbuild in Jenkins that allows me to count strings and determine if the build succeeded by how many the count returns at the end. </p>
  
  <p>Here is my example code :</p>
  
  <pre><code>class Main {
  
    def manager = binding.getVariable("manager")
    def log = manager.build.logFile.text
    def list = log
    def JobCount = list.count {it.startsWith("====") &amp;&amp; it.contains("COMPLETE")}
    if (JobCount == 7) {
        manager.listener.logger.println("All Jobs Completed Successfully")
    } else {
        manager.addWarningBadge("Not All Jobs Have Completed Successfully")
        manager.buildUnstable()  
    }
  }
  </code></pre>
  
  <p>I am looking for a specific string that gets printed to the console when the test has completed successfully. The string is "====JOB COMPLETE====" and I should have 7 instances of this string if all 7 tests passed correctly. </p>
  
  <p>Currently when I run this code I get the following error :</p>
  
  <pre><code>Script1.groovy: 6: unexpected token: if @ line 6, column 5.
     if (JobCount == 7)
     ^
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>