chanukhya bachina
chanukhya bachina

Reputation: 181

Build function doesn't return a build object if FAILED or UNSTABLE

I'm using the build flow in my jobs and I would like to get any build result from build object even if the build is failed or unstable. For example:

try{ BUILD_TO_RETURN = build(parameters: newparams, job: jobName, quietPeriod: 5); println("Result is: " + BUILD_TO_RETURN.getResult()); // THIS LINE IS NOT BEING CALLED IF THE BUILD IS UNSTABLE } catch(Exception e) { if (e instanceof InterruptedException || e.getCause() instanceof InterruptedException) { throw e; } else if( e.toString().contains("UNSTABLE") || e.toString().contains("FAILURE")){ println("buildJob : No exception, the job result: ${e}"); // THIS LINE IS BEING CALLED return BUILD_TO_RETURN; }

What actually happening is that BUILD_TO_RETURN returned is null. Which means an exception was thrown for UNSTABLE build. I would like rather to have the UNSTABLE build object in my hands and return it.

Is it possible to "ignore" failure\unstable build and do not ignore all other exceptions?

Upvotes: 0

Views: 466

Answers (1)

Jesse Glick
Jesse Glick

Reputation: 25481

Add: propagate: false to your build step to get this behavior. Snippet Generator should be offering that as an option, with an inline help button.

Upvotes: 2

Related Questions