title: Jenkins - Is there a way to parse console output and set environment variable
body: <p>I am relatively new to Jenkins. I am into a scenario where I need to read the console output and find a specific string and set this as environment variable. This variable I would be using in some downstream jobs.</p>
  
  <p>for example: my jenkins job's console would contain something like </p>
  
  <p><code>product_build_number: 123456</code></p>
  
  <p>I have looked into FindText, log parser like plugins but they don't help me in setting this value as environment variable</p>
  
  <p>Can somebody help in finding this number and pass it to downstream jobs?</p>
  
  <p>**</p>
  
  <blockquote>
    <p>Updated with Answer:</p>
  </blockquote>
  
  <p>**</p>
  
  <pre><code>def matcher = manager.getLogMatcher(".*product_build_number=(\\d+.*)")
  if(matcher.matches()) {
      pbn= matcher.group(1).substring(0)
      manager.build.setDescription(pbn) // you can do anything with this here
  }
  </code></pre>