8

I want to access the log of another post-build action, which runs right before the groovy postbuild.

The console output looks like this:

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.48
Code Metrics Report path: **/*.Metrics.xml
Code Metrics Report Not Found.
Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE

I cannot use manager.logContains() because the output was generated by another post-build action.

I can set the build status to SUCCESS, but I want to do it only if the post-build action logged Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE

if (manager.build.result == hudson.model.Result.UNSTABLE 
        && ???.contains("Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE") {
  manager.build.@result = hudson.model.Result.SUCCESS
}
  • Another approach without groovy is to download the console logs e.g. wget http://:8080/job///consoleText and then using regex grep this output and take further decisions – vaibhavnd Jul 05 '16 at 10:30

1 Answers1

0

You can try using manager.build.logFile.readLines().

For example,

if (manager.build.result == hudson.model.Result.UNSTABLE

        && manager.build.logFile.readLines().contains("Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE") {

    manager.build.@result = hudson.model.Result.SUCCESS

}

See Oni Dar's excellent answer for an example.

Rao
  • 20,781
  • 11
  • 57
  • 77
Daniel Omoto
  • 2,431
  • 17
  • 15