doLast regardless of task result

I am defining/overwriting a task where I want to add a closure (which needs data defined in the actual task) which should be executed after running this task, regardless if the task was executed successfully or not.

doLast is doing the job fine, but only if the task does not fail. Is there something similar to doLast which is called always?

My use case: I am running webtests with geb/spock. And I want to generate an index.html into the “geb”-directory where html and screenshots are saved. I need this index.html for jenkins HTML-Report plugin.

You’ll have to use a [TaskExecutionListener]( for this.