Steph M
Steph M

Reputation: 2172

How do you kill a drone.io (0.8.1) job after a step takes a certain amount of time?

I'm using drone 0.8.1. I have some UI tests that run as steps and sometimes they get stuck and can hang for up to an hour. I'd rather kill the entire drone build after a step takes longer than a set amount of time (say, 5 minutes since I know that each step should only take ~30 seconds to complete) rather than waiting an hour to find out that my drone build was cancelled.

Essentially, I just want a way to say "Is this drone step taking more than X minutes? Then kill the entire build".

I'm not seeing anyway to do this in the docs but wondering if someone has finagled a way to do this? Much appreciated!

Upvotes: 1

Views: 338

Answers (1)

kalehmann
kalehmann

Reputation: 5011

You should be able to achieve this with the timeout command.

This command allows you to limit the time for a command. Add it to your image and prefix every command with it.

Since it also exits with a non-zero code if the time limit is exceeded, your step will automatically fail.

Example usage:

commands:
    - timeout 30s doSomethingLong.sh

Upvotes: 1

Related Questions