3

We have a database tester build that first clones a database before it runs the tests. We would like to prevent this build from being stopped/cancelled by a user. The problem is, if the build is cancelled/stopped manually during the cloning process it leaves the DB in a bad way and requires DBA intervention.

Is there a way to prevent a build step from being cancelled/stopped?

Andrew Burns
  • 346
  • 4
  • 15

2 Answers2

1

I don't think you can do that in TeamCity. The best you can do is detach the cloning process from TeamCity, so cancelling the build in TeamCity won't touch the cloning process. (E.g. use a Powershell build step which calls Start-Process myCloningProcess.exe -Wait.)

Of course, there is a more general problem: how do you prevent the cloning process from being killed at all (e.g. by someone working on the TeamCity agent, not via the TeamCity GUI)? You can't. Hence, the solution above will only deal with the risk in the context of TeamCity; it won't solve this more general issue.

sferencik
  • 3,144
  • 1
  • 24
  • 36
  • Thanks, would setting the build execution step settings " Always, even if build stop command was issued" work? I mean even if the Stop was issued this step should still continue to execute? – Andrew Burns Nov 26 '15 at 10:37
  • I think that setting only applies to the steps _following_ the cancelled step. Suppose your build configuration has three steps, A, B, C. Your build starts and while A is running, you cancel it. TeamCity will kill A and would by default skip B and C, but since C has the "Always, even if build stop command was issued" setting, it still runs C. Useful if C does some vital clean-up. To summarise, such a build will have run _half_ of A and C. – sferencik Nov 26 '15 at 12:58
1

You can archive it using Roles and Permissions. The permission called "Stop build / remove from queue". So you can create a role in TeamCity without permission to stop builds and create a separate project for database cloning. Then grant users/groups with this role for the database clone project.

billw
  • 120
  • 1
  • 9
Alina Mishina
  • 3,320
  • 2
  • 22
  • 31