Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Analize a step log to extract info from application log #4052

icnaan ·

Robin
I am using a CLI tool that I have no access to it's code, the information I wish to return to the build flow is in the CLI STD output, I have tried to add a script in the Post-Execute Action and with the idea to analyze the log output of the CLI and using some String manipulation and vars.get().setValue() to communicate the information picked up from the log to the other steps int he build.
I added this code:


groovy:
logger.info "build ==" + build;
logger.info "Output ==" + build.renderLogAsText();


I get a object of the build alright, but the nothing back from build.renderLogAsText()

I assumed that log is not ready at the time of the execution and tried build.getPrevious().renderLogAsText(); - this also return nothing
Any idea of now to properly analyze a CLI output ?
Note: I have seen the Analyze logs option ... I am not trying to decide the success - I am trying to get info from the log stream.

P.S. the log is something like: "Map version found - 1.02 - new map version is - 1.05"

  • replies 5
  • views 29
  • stars 0
icnaan ·

A bit of info:
System Date and Time 2019-02-19 16:41:06
Operating System Linux 3.0.101-108.13.1.14249.0.PTF-default, amd64
JVM Java HotSpot(TM) 64-Bit Server VM 1.8.0_141, Oracle Corporation
QuickBuild Version 8.0.36 - Thu Jan 31 06:47:48 IST 2019
Total Heap Memory 7.11 GB
Used Heap Memory 1.23 GB

robinshen ADMIN ·

Instead of calling your cli tool with shell/batch step, use a script execution step (misc/execute specified step) to run below script:

groovy:
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = '/path/to/your/cli'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
// do some parse here against sout and store the result as sResult
vars.getValue("someVar").setValue(sResult);
icnaan ·

neat - thanks
I had a fixation on being able to analize the Stderr / stdout while the CLI logs in the usual way .. this will work.
Thanks

icnaan ·

the last line should be:

vars.get("someVar").setValue(sResult);
robinshen ADMIN ·

My mistake. Thanks for pointing this out.