TeamCity Cancelling Builds Problem

When we cancel a build we would like to close all handles and stop the build gracefully.
To this end we have tried Signal-Handlers and Console-Control-Handlers to intercept the kill signal thrown by the Build Agent.
Unfortunately none of these handlers can intercept the kill switch.

Is there a way to intercept the kill signal?

14 comments

Abraham,

There is no dedicated way to affect build cancelling procedure.
Please vote for/watch TW-10265.

A workaround might be to implement a TeamCity plugin that will listen for build events and will execute custom logic before the standard one kills the processes.

0

What kind of plugin would that be and where can I get an example?
Thanks.

0

Your response was technically the answer to my question.
Sadly I pressed the wrong button.
Sorry.

0

Abraham,

That would be an agent plugin that will override
AgentLifeCycleAdapter.beforeBuildInterrupted method to implement all the actions inside it.

There is no good and simple example of an agent plugin.
One example can be found in XML test reported plugin: XmlReportPlugin class has some slike listeners.

Feel free to ask us more specific questions on this.

0

We have decided to implement our own build runner.
I have already started work on it but I need the JSP and .CLASS files for the Command-Line build runner.
I have tried looking in the TeamCity install directory but couldn't find the .JAR file.

Can you tell me where to find the JAR file so that I can extract the JSP files and the Class files.
I can reverse engineer the the .JAVA files from the .CLASS files.
Thanks

0

Abraham,

What you mean is probably located injetbrains.buildServer.commandline package and commandlineSettings.jsp

If the only feature you need it to custom-process build cancelling, writng own runner seems to be much larger task then necessary.
TeamCity 6.0 (including current EAPs) has changes in open API related to multiple build steps. Please review open API changes. However, they are not meant to be cmplete, please refer to 6.0 EAP devPackage for the current API.

PS I am not sure how reverse engineering lines up with TeamCity license agreement nor am I entitled to give official comments on this.

0

I just tried searching for  commandlineSettings.jsp in my teamcity install directory and found nothing.

My aim is not just to cancel the build but to send a Kill signal to the build program such that it can close gracefully.
I tried reading the TeamCity 6.0 reference that you sent but I am not sure how the changes in 6.0 can help me send a Kill signal when a build is stopped.

Also I am not sure when we will be switching to TeamCity 6.0...

Thanks

0

Any suggestions on how to get that jsp file.
Also I should mention that We will NOT be reverse engineering the .CLASS file for the command line runner because according to our legal departmenet that would indeed violate the terms of our contract.

0

Abraham,

Apparently, I was wrong with the jsp name, sorry for taht. The right one is simpleRunnerParams.jsp

You should be able to execute arbitrary custom actions in AgentLifeCycleListener.beforeBuildInterrupted method.

I noted open API changes as those to watch if you will be writing your plugin for TeamCity 5.x and then will be upgrading to 6.0.

0

The reason we don't want to use AgentLifeCycleListener.beforeBuildInterrupted is that we don't want the kill signal to be tied in with the Accurev Plugin or any other VCS plugin.
That is why we have opted for a separate Build Runner.

0

> The reason we don't want to use AgentLifeCycleListener.beforeBuildInterrupted is that we don't want the kill signal to be tied in with the Accurev Plugin or any other VCS plugin.

So far I am not sure how this listener is related to VCS plugins... This is a general "core" agent listener that works without any VCS plugins involved.

0

That sounds perfect.

How would I integrate this AgentListener With the TeamCity server....
I assume that I would have to make a JAR file and then place it somewhere...

And Could this AgentListener Have access to the Build-Runner's parameters since I need to send the build program a kill switch which will only be possible if I have access to those parameters.
On the otherhand I could just enumerate all active processes and Kill the one who's name matches the expected name of the build program.
However the First solution seems more elegant.

Thanks

0

I have implemented My own AgentLifeCycleAdapter.
How do I Install it in TeamCity?

Thanks

0

Abraham,

Sorry for the delay with replying.

You should add an agent-side part of plugin (see how to package a plugin) and register the listener as described in the doc.

0

Please sign in to leave a comment.