Resolving Parent-Child Pipeline Lifecycle Binding: Protecting Uninterruptible Hardware Flashing Tasks while Maintaining Synchronous Execution

I am currently facing a parent-child pipeline lifecycle binding issue. When the parent pipeline reaches Stage 4, it triggers a child hardware flashing task. Sometimes, I need to cancel the parent pipeline.

However, if the parent pipeline is currently in Stage 4, I do not want it to be canceled, because the child flashing task triggered in Stage 4 is uninterruptible. The subsequent stages in my parent pipeline require the child task to complete and return a successful status before they can proceed. What would be a good approach to solve this problem?

I think the tricky part here is that cancelling the parent job and stopping the actual flashing operation really need to be treated as two different things.

Maybe the child flashing job should run independently, with its own lifecycle, while the parent waits for its result.

That way, cancelling the parent wouldn’t automatically kill a flash that’s already in progress.

One thing I’d be careful about, though, is what happens afterward. If the parent has been cancelled but the flash finishes successfully, you’d still need a reliable way to record that result and avoid starting another flash on the same device too early.

I’m curious whether your flashing hardware is already protected by some kind of device lock or queue?

There is a Pipeline step for separating those two parts: start the downstream build, then wait for it with abort propagation disabled.

def flash = build job: 'hardware-flash', waitForStart: true
def finished = waitForBuild runId: flash.externalizableId,
    propagate: true, propagateAbort: false

With that arrangement, the parent still waits during normal execution and does not proceed successfully unless the flashing build succeeds. If the parent is cancelled while waitForBuild is waiting, the parent stops, but that wait does not attempt to cancel the flashing build. These options are documented under Pipeline: Build Step.

That does not make the parent uncancellable or guarantee that the hardware operation survives an agent/controller failure. Put the device lock in the flashing job itself and keep the result there, so cancelling the parent cannot release the device early. The remaining decision is whether cancelling the parent should be allowed at all during Stage 4, or whether it may stop while the independently protected flashing job finishes.