Terminate CI if it Runs Too Long

Is there a way to terminate CI if the jobs end up running too long? I’m having an issue where on occasion our 5-minute tests will end up taking up to an hour. I’d love to terminate it instead of wasting precious CPU cycles.

Yep, just use the timeout shell command prior to your potentially long-running command.

(So for me, I’d do something like timeout 5m phpunit --stop-on-fail --stop-on-error).

Thanks, I’ll give it a shot. It’s not necessarily a particular command that’s taking a while, but the whole container. Here’s another example that took almost an hour and a half. 24 containers ran without any issues, just one bad container there.

If you have a process that is tracking how long the step is running you can either cancel it via API if it’s external, or circleci halt if it’s internal.

Can you look at the history of that container to get any clues as to why it took so long?