It's all about the answers!

Ask a question

Can waitForTeamBuild Abandon a build?


Cristian Gheorghe (122) | asked Mar 21 '13, 6:51 p.m.
edited Mar 22 '13, 8:47 a.m. by Spencer Murata (2.3k115971)
I am using Rational Software Architect to launch headless builds via the JBE v4.0 as a scheduled overnight build. 

I have a PMR open with Rational regarding issues related to builds that sometimes hang in headless mode under Linux (using RHEL Server 6.2). In the meantime, thought I would start the builds using startBuildActivity combined with waitForTeamBuild, such that I can use the timeout value to essentially have a build Abandoned if it misbehaves and lasts longer than it should, and hopefully in the process populate buildStateProperty with INCOMPLETE such that I can then have a new build triggered, if if find that the build has been Abandoned.

I have put together a quick test. The waitForTeamBuild did work, in the sense that after my timeout value (60 secs for this test) it has triggered, however to my surprise, my buildStateProperty did not get set. 

                <waitForTeamBuild repositoryAddress="${repositoryAddress}"
                        userId="${mdmb.user}" passwordFile="${mdmb.passfile}"
                        buildResultUUID="${zLinuxBuildResultUUID}"
                        buildStateProperty="zLinuxBuildState"
                        buildStatusProperty="zLinuxBuildStatus"
                        statesToWaitFor="COMPLETED, CANCELED, INCOMPLETE"
                        verbose="true" timeout="60"/>

                <echo message="Build state is: ${zLinuxBuildState}"/>
                <echo message="Build status is: ${zLinuxBuildStatus}"/>

And I got this in the log.

     [echo] Build state is: ${zLinuxBuildState}
     [echo] Build status is: OK

The documentation for waitForTeamBuild mentions what code is returned in various states, so I thought that a timeout would cause the build to enter the  INCOMPLETE, therefore setting buildStateProperty to INCOMPLETE as well.

RTC4.0 docs --> INCOMPLETE: the build did not complete normally. Also referred to as abandoned.

Since my buildStateProperty is not getting set to anything but the timeout value is honored, I suppose I must be misunderstanding the way I could use the timeout parameter to have a build Abandoned. In fact, now that I think about it, the build is actually not even been abandoned, since it does continue running on the server, which in turn would mean that if my build is hung, I could not even get another build started since only one build definition can run at any one time. I suppose I am looking for a way to have the build been actually Abandoned on a timeout value if I am to be able to kick start a new build via a new build definition.

Any ideas/advice would be very appreciated, thank you.

2 answers



permanent link
Spencer Murata (2.3k115971) | answered Mar 22 '13, 8:55 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
 In this case I can confirm that waitForTeamBuild is working as expected.  Just because the task has expired does not mean that the build has been abandoned, the build will continue to run regardless.  You might be able to use the completeTeamBuild, and set it as an error if the Ant script has run for so long, but I am not sure if that will work or not.  Generally that is used to manually complete a build from Ant, not interjecting a complete command to a build doing something else.  Its very possible that whatever command has hung the build will block other attempts to manipulate the build state.

I don't think that there is a good workaround in this case for stopping builds from hanging, short of fixing whatever the problem is.

~Spencer

Comments
Cristian Gheorghe commented Mar 22 '13, 9:07 a.m.

Thanks for your response Spencer.


When the build hangs, I can definitely abandon the build when I use the GUI, no problem there. I am also not trying to resolve the issue of hanging builds either, that has to be taken care of by Rational. 

At this time, when a build hangs, I use the GUI to Abandon the build, which works fine, and subsequently launch a new build. If the build hangs, most of the time, it completes fine on a second attempt. Whether or not I kill the process on the machine is also irrelevant, nice to be able to do so from a resource perspective, but not necessary. The process of the abandoned build can continue to live on the machine independent of the process which will be launched by the next build.

I am looking for a solution that I could use, to have a build Abandoned if it takes longer than a certain time, by using the RTC ANT tasks. I suppose nothing comes to mind, right? 


permanent link
Nick Edgar (6.5k711) | answered Apr 13 '13, 2:20 p.m.
JAZZ DEVELOPER
It appears waitForTeamBuild only sets the build state property if one of the expected states has been reached, not in the case of a timeout. It may have been done that way so the script can detect the timeout case, i.e. the state property is unset.
That said, it does seem problematic that there's no way to get the current state in the case of a timeout.  FYI the state would still be IN_PROGRESS.  You can probably just assume that if it's not one of the states you list, it's still IN_PROGRESS.

As for actually marking the build as abandoned, we apparently have no Ant task to do that, unfortunately.  We have the completeTeamBuild task, but that's for normal completion, and does not support abandon.  I've opened enhancement request Provide a way to abandon a build via Ant task (260590)

It could also be done via the Java client API.  The relevant API is:
com.ibm.team.build.client.ITeamBuildRequestClient.makeBuildIncomplete(IBuildResultHandle, String[], IProgressMonitor)

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.