Skip to content

finalizedBy does not work when task fails and the target task depends on origin task #27707

@nbrugger-tgm

Description

@nbrugger-tgm

Current Behavior

With this config:

val cleanup = tasks.register("cleanup") {
    doLast {
        throw GradleException("cleanup should fail too!")
    }
	dependsOn("failing")
}

val failing = tasks.register("failing") {
	doFirst {
        throw GradleException("OH no! I Failed! I need cleanup!")
    }
    finalizedBy(cleanup)
}

executing failing does not trigger cleanup afterwards.

When the dependsOn is removed it works correctly

Expected Behavior

cleanup is able to depend on failing without breaking the finalizedBy constraint

Context (optional)

No response

Steps to Reproduce

https://github.com/nbrugger-tgm/gradle-issue-reproducer

  1. ./gradlew failing

Gradle version

8.4, 8.5

Build scan URL (optional)

No response

Your Environment (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugThis doesn't work as expectedclosed:invalidNot applicable to Gradle or EOL versionin:schedulerexecution plan, task graph, work lease, project lock

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions