's after_script doesn't work

28 Jun 2015

I was stuck at this problem for almost 5 hours. It's difficult to debug because of a long test cycle.

I've found that, when a command in the script block fails, the after_script block is not run at all.

After trials and errors for 5 hours, I've found that it is because I change the working directory (e.g. using cd). When an error occurs in the working directory that is not root, any sub-sequential task will not be run. I'm pretty it's a bug.

Anyway, the way to solve it is to switch to the new folder ephemerally, though it's not straightforward.

Here's a combination that works:

script: - (cd test_test/ && exec some_program)

If some_program fails, the after_script will still be run.

Here's a combination that does NOT work:

script: - (cd test_test/ && some_program)

I've filed an issue for here:

I hope it gets fixed soon.

Give it a kudos