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.

How to make groovy script step to fail the build? #1974

arkady.itkin ·
I tried to return non-zero value (as well as zero) from the script but it does not affect the build.
  • replies 8
  • views 4990
  • stars 0
robinshen ADMIN ·
You may throw exception directly in the script like below:
groovy:
throw new com.pmease.quickbuild.QuickbuildException("Build is failed intentionally!");
arkady.itkin ·
Robin,

When I through an exception from within script step it prints out the whole stack trace that makes it difficult to understand the log.
Is there any way to control what will be printed out to the log or any other way to fail the step execution w/o printing full stack trace to the log?
robinshen ADMIN ·
If you are on the latest QB version, the error should be obvious by checking the build overview page. The log output is for tracing purpose.
arkady.itkin ·
Agree.
But when one is troubleshooting build problems it's very inconvenient when log is overwhelmed by irrelevant information.
In this specific case the trace prints out the whole groovy script and claims there is an interpretation error which is confusing.

I think more option to control log behavior may be useful.
robinshen ADMIN ·
Please submit an improvement request for this at track.pmease.com
satyam ·
Hello Robin,

I also agree the with the above behaviour.
Its very hard for developers to find the error. We are admin and can check the error but developers need exact information.

Regards,
Satyam.
marko ·
Did anyone ever submit a request for this and was a solution implemented?

I just ran across this situation today. I have a step that executes groovy and I want to fail the build in certain situations. The only way I could figure out how to do it was to throw an exception.

I don't like doing that because it logs the call stack and looks like something is horribly wrong with the groovy code or QuickBuild itself.

People see that call stack and immediately assume that something is seriously wrong with QuickBuild or the groovy script.

It would be nice to just give them a message that provides a simple message as to why we purposely failed the build.

I'm thinking something like

step.setStatus(Status.Failed, "Failed because I did not want this step to succeed.") 

or

step.fail("Failed because I did not want this step to succeed.") 


The log would then look something like


16:24:56,960 INFO - Executing pre-execute action...
16:24:56,960 INFO - Running step...
16:24:56,997 INFO - Checking step execute condition...
16:24:56,998 INFO - Step execute condition satisfied, executing...
16:24:58,027 INFO - Executing pre-execute action...
16:24:58,027 INFO - Running step...
16:24:58,061 ERROR - Failed because I did not want this step to succeed.
16:24:58,086 INFO - Executing post-execute action...
robinshen ADMIN ·
Please monitor the issue http://track.pmease.com/browse/QB-1581. It will be solved in next patch release which should be available in a few hours. In the new patch release, you may indicate failure of the step by throwing QuickbuildException and QB will ONLY log the strack trace in TRACE logging mode.