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.

Parse build log in Notification #3072

zoywiki ·
How can I parse the log of the last run build of a configuration in a template?

I would like to add some additional text to the Notification email sent out so that lists specifically some text such as

- WARNING: Some file was empty

Where the text "WARNING: Some file was empty", appeared in a build step log, but was not a failed build.
  • replies 7
  • views 5185
  • stars 0
robinshen ADMIN ·
You may save the build log to a text file in post build script (can be defined in advanced setting of the configuration) and parse that text file to get desired messages to write another file like below:
groovy:
def logFile = new File(configuration.workspaceDir, "log.txt");
build.saveLogAsText(logFile);
def messageFile = new File(build.publishDir, "message.txt");
// read the logFile with groovy to parse out desired messages.

Then you can configure the email notification template to attach the message file, or in QB6 to include the message file in notification template by adding:
#include "message.txt"
zoywiki ·
I have put this code on the Post execute action of the master step and it causes IO Error.

I was trying to just capture all the output from the run and then go find the "log.txt" file in qb workspace dir manually.

12:05:31,351 TRACE - Stack trace for the failure
java.lang.RuntimeException: Failed to evaluate below expression:
groovy:
def logFile = new File(configuration.workspaceDir, "log.txt");
build.saveLogAsText(logFile);
at com.pmease.quickbuild.util.ExceptionUtils.wrapException(ExceptionUtils.java:87)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:94)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction.execute(ScriptExecuteAction.java:36)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c.CGLIB$execute$1(<generated>)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c$$FastClassByCGLIB$$fc9f8871.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:273)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c.execute(<generated>)
at com.pmease.quickbuild.stepsupport.Step.execute(Step.java:561)
at com.pmease.quickbuild.stepsupport.StepExecutionJob.executeStepAwareJob(StepExecutionJob.java:30)
at com.pmease.quickbuild.stepsupport.StepAwareJob.executeBuildAwareJob(StepAwareJob.java:45)
at com.pmease.quickbuild.BuildAwareJob.execute(BuildAwareJob.java:60)
at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:73)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.pmease.quickbuild.QuickbuildException: java.lang.RuntimeException: java.io.EOFException
at com.pmease.quickbuild.model.Build.saveLogAsText(Build.java:1076)
at com.pmease.quickbuild.model.Build.saveLogAsText(Build.java:1084)
at com.pmease.quickbuild.model.Build$saveLogAsText.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at script1421168727819987796540.run(script1421168727819987796540.groovy:4)
at com.pmease.quickbuild.plugin.basis.BasisPlugin$28.evaluate(BasisPlugin.java:347)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:81)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction.execute(ScriptExecuteAction.java:36)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c.CGLIB$execute$1(<generated>)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c$$FastClassByCGLIB$$fc9f8871.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:273)
at com.pmease.quickbuild.setting.step.executeaction.ScriptExecuteAction$$EnhancerByCGLIB$$64e3d4c.execute(<generated>)
at com.pmease.quickbuild.stepsupport.Step.execute(Step.java:561)
at com.pmease.quickbuild.stepsupport.StepExecutionJob.executeStepAwareJob(StepExecutionJob.java:30)
at com.pmease.quickbuild.stepsupport.StepAwareJob.executeBuildAwareJob(StepAwareJob.java:45)
at com.pmease.quickbuild.BuildAwareJob.execute(BuildAwareJob.java:60)
at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:73)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2601)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1319)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at com.pmease.quickbuild.log.BuildLogTextStream.read(BuildLogTextStream.java:56)
at java.io.InputStream.read(InputStream.java:170)
at java.io.InputStream.read(InputStream.java:101)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1033)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1007)
at com.pmease.quickbuild.model.Build.saveLogAsText(Build.java:1074)
... 24 more
at com.pmease.quickbuild.plugin.basis.BasisPlugin$28.evaluate(BasisPlugin.java:371)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:81)
... 16 more
robinshen ADMIN ·
Please switch to advanced setting of the configuration instead of master step, and from there you will see a post-build script field. Build log should be saved/parsed there.
ptrinh ·
I used the following script in the Post-Execution action for saving the QB logs to log.txt in the workspace, but the log file is empty. Looks like the logs were not written to the file. Please advise. Thanks,
groovy:
def logFile = new File(configuration.workspaceDir, "log.txt");
build.saveLogAsText(logFile);
robinshen ADMIN ·
Do not put them in post-execute script of a step. Put it in post-build script of the configuration (can be defined in advanced setting of the configuration) instead.
wrobins ·

My log is saving on the server rather than the node the build is running on.
How can I have this saved on specific agent?

Im using the post-execute script under advanced settings.

Thanks

robinshen ADMIN ·

Log can only be saved on server. You will need to run your log parsing logic on server also.