Jenkins - How to set environment variables using Groovy Postbuild plugin
<p>I have done a lot of google for  this issue and found nothing that would help to solve my issue.</p>

<p>I am trying to parse the Jenkins job's console output and set environment variable. I would need this variable in my parent job which would be running on different slave.</p>

<p>I could fetch the string value I need from the console output using </p>

<pre><code>def build = Thread.currentThread().executable    
def matcher = manager.getLogMatcher(".*myEnvironemntValue: (.*)")

if(matcher != null &amp;&amp; matcher.matches()) {
    log('found my value')
    myEnvironemntValue= matcher.group(1).substring(0)
    def pa = new ParametersAction([
          new StringParameterValue("MY_ENV_VALUE", myEnvironemntValue)
    ])
    build.addAction(pa)
    manager.addInfoBadge(myEnvironemntValue)
}
</code></pre>

<hr>

<h3>Update</h3>

<p>I have a <a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin" rel="nofollow">buildflow</a> job (parent job) from which I will call other child jobs using DSL script something like</p>

<pre><code>def b1 = build("child_job1", NODE: node)
def b2 = build("child_job2", NODE: node)
</code></pre>

<p>Child job <code>child_job1</code> and <code>child_job2</code> are multiphase jobs, they invoke other jobs in turn in various phases, say <code>phase1_job</code>, <code>phase2_job</code> and <code>phase3_job</code></p>

<p>Once the job <code>phase3_job</code> is done executing, I would want to get a specific value from its console. </p>

<hr>

<p>Could someone help in resolving this issue? I am fine to use other plugins if they help me getting the console value and setting it as environment variable</p>