I have done a lot of google for this issue and found nothing that would help to solve my issue.
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.
I could fetch the string value I need from the console output using
def build = Thread.currentThread().executable
def matcher = manager.getLogMatcher(".*myEnvironemntValue: (.*)")
if(matcher != null && 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)
}
Update
I have a buildflow job (parent job) from which I will call other child jobs using DSL script something like
def b1 = build("child_job1", NODE: node)
def b2 = build("child_job2", NODE: node)
Child job child_job1
and child_job2
are multiphase jobs, they invoke other jobs in turn in various phases, say phase1_job
, phase2_job
and phase3_job
Once the job phase3_job
is done executing, I would want to get a specific value from its console.
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