It's all about the answers!

Ask a question

Gracefully terminating an inprocess build


Clayton Coleman (131) | asked Oct 11 '09, 4:37 p.m.
Is there a recommended way to terminate an in-progress ant build from within the build itself?

The behavior I'm looking for is similar to the "buildNotNecessary" flag on CompleteBuildTask or the Jazz SCM "build only if changes were accepted", but executed by the ant build script itself. I'm currently emulating this function by calling:


getTeamBuildRequestClient().makeBuildIncomplete(getBuildResultHandle(), IBuildResult.PROPERTIES_REQUIRED, getProgressMonitor());
getTeamBuildClient().delete(getBuildResultHandle(), getProgressMonitor());


from a custom ant task and then invoking the ant <fail> task. The build is correctly terminated and the result deleted, but the build loop then catches and writes an exception after the ant build completes (because it attempts to call makeBuildComplete on a build result that has already been deleted).

Is there a graceful way to accomplish this via the Java API from within an in progress ant task? Is there something that would allow me to notify the build loop via ant properties that the build should be abandoned / removed? Or is this something I should be attempting via a pre-build participant (stop the build before it starts) or post-build participant (detect that an ant property has been set and delete the build result after completion)?

2 answers



permanent link
David Olsen (5237) | answered Oct 13 '09, 12:46 a.m.
JAZZ DEVELOPER
claycole wrote:
Is there a recommended way to terminate an in-progress ant build from
within the build itself?

I don't think so. I haven't explored doing it through Java. There is
no way to do it through Ant. A few months ago I opened enhancement
87583
(https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/87583)
requesting an Ant task to do that.

permanent link
Nick Edgar (6.5k711) | answered Oct 14 '09, 11:56 a.m.
JAZZ DEVELOPER
JBE should handle this better. After the script returns, it should check whether the build result has been deleted, or has already been completed, before trying to upload the build log and mark the build as completed.

I've filed 96664: BuildLoop should check for deleted / completed build after running script for this, and subscribed you.

See also 95289: Ant task to delete a build result.

Regards,
Nick

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.