Killing a running build via a teamcity plugin

Is there a way that I can kill a running build using a teamcity java plugin? I am struggling to find one that works for a Running Build. 

4 comments
Comment actions Permalink

You can stop a build using the jetbrains.buildServer.serverSide.SRunningBuild:stop method

0
Comment actions Permalink

Dmitry, 

Thanks for the quick response. I actually left out a part of that question that I realize now. I am trying to stop a previous build. I am getting the previous build using the jetbrains.buildServer.serverSide.BuildPromotion.getPreviousBuildPromotion method. using the SINCE_LAST_BUILD enum constant so it should get me the last build in the current branch that is running, finished... The problem is that because this is now of type BuildPromotion. Meaning .stop() doesn't work. any tips as to how to get the previous build and stop it.

 

0
Comment actions Permalink

Max,

Given that you have a `BuildPromotion` instance you can call `getAssociatedBuild` method on it.

Then you need to check whether this build is not null and is running using `instanceOf SRunningBuild` check. Then you can cast the build to  SRunningBuild and call stop on it.

0
Comment actions Permalink

Thanks! 

 

0

Please sign in to leave a comment.