> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/mark-as-failed-pipeline.md).

# Mark pipeline as failed

Mark a pipeline as failed during execution to stop all running and queued stages.

You can manually stop a running pipeline by marking it as failed. The **Mark as Failed** button on the pipeline execution details page allows you to trigger failure handling for the pipeline and its currently running stages.

***

## What you will learn from this topic

* How to [mark a pipeline as failed](#mark-a-pipeline-as-failed) during execution.
* Understand the [difference between marking a stage as failed and marking a pipeline as failed](#marking-a-pipeline-vs-a-stage-as-failed).
* Understand [which failure strategy runs](#failure-strategy-that-runs-when-you-mark-a-pipeline-as-failed) when you mark a pipeline as failed.

***

## Before you begin

* **Pipeline permissions**: You must have Execute permissions on pipelines to mark a pipeline as failed. For more information, refer to [Manage roles](https://developer.harness.io/harness-platform/use-harness-platform/platform-access-control/add-manage-roles.md).
* **Account setting enabled**: You must enable **Allow users to mark a running Step as failure** in your Harness account's [default settings](https://developer.harness.io/harness-platform/use-harness-platform/settings/default-settings.md).

***

## Mark a pipeline as failed

Perform the following steps to mark a running pipeline as failed:

1. Navigate to the pipeline execution details page.
2. Click **Mark as Failed**.

![](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-21a33aa5d1c72d20997c5da9995d0252084cd539%2Fmake-pipeline-as-failed1.png?alt=media)

After you mark a pipeline as failed, Harness fails `running` and `queued` stages. Completed stages are not marked as failed.

{% hint style="info" %}
If a pipeline is configured with failure strategy like `Ignore Failure` or `Retry`, the execution might continue even after `Mark as Failure` is sent.
{% endhint %}

***

## Marking a Pipeline vs. a Stage as Failed

You can manually mark either an entire pipeline or an individual stage as failed. The behavior differs depending on whether other stages are running at the same time.

* If only one stage is running when you mark the stage or pipeline as failed, both options have the same effect.
* If multiple stages are running in parallel, marking the **pipeline** as failed stops all running stages. Marking a **stage** as failed stops only that stage.

***

## Failure strategy that runs when you mark a pipeline as failed

The failure strategy that runs when you mark a pipeline as failed depends on the following configuration:

* The failure strategies configured at the step and stage levels.
* The step that is running when you mark the pipeline as failed.

When you click **Mark as Failed**, Harness sends a failure interrupt to the stages currently running, triggering their failure strategies. Harness checks the failure strategy in this order: step, then stage. If the running step has its own failure strategy that covers the error type, that strategy applies and the stage failure strategy does not. If the running step has no failure strategy of its own, the stage failure strategy applies.

A stage-level **Rollback Pipeline** strategy therefore runs after you mark a pipeline as failed only when the strategy that handles the user-marked failure for the running step is **Rollback Pipeline**. Otherwise, the rollback does not run.

### Example: step Manual Intervention overrides stage rollback

In this example, the stage has a **Rollback Pipeline** failure strategy for all errors, and the `Rolling_Deployment` step has its own **Manual Intervention** failure strategy for all errors.

<details>

<summary>Stage and step failure strategy YAML</summary>

```yaml
- stage:
    name: Deploy_Stage
    identifier: Deploy_Stage
    type: Deployment
    spec:
      deploymentType: Kubernetes
      service:
        serviceRef: example_service
      environment:
        environmentRef: example_environment
        deployToAll: false
        infrastructureDefinitions:
          - identifier: example_infrastructure
      execution:
        steps:
          - step:
              name: Rolling Deployment
              identifier: Rolling_Deployment
              type: K8sRollingDeploy
              timeout: 10m
              spec:
                skipDryRun: false
              failureStrategies:
                - onFailure:
                    errors:
                      - AllErrors
                    action:
                      type: ManualIntervention
                      spec:
                        timeout: 4h
                        onTimeout:
                          action:
                            type: Ignore
    failureStrategies:
      - onFailure:
          errors:
            - AllErrors
          action:
            type: PipelineRollback
```

</details>

The YAML defines two failure strategies:

* **Step level:** `failureStrategies` under the `Rolling_Deployment` step uses the `ManualIntervention` action for `AllErrors`. If the step times out after `4h`, the `onTimeout` action is `Ignore`.
* **Stage level:** `failureStrategies` under the stage uses the `PipelineRollback` action, which is **Rollback Pipeline** in the UI, for `AllErrors`.

Because the step has its own strategy that covers all errors, it takes precedence over the stage strategy for that step.

The result depends on which step is running when you click **Mark as Failed**:

| Running step when you mark the pipeline as failed                        | Failure strategy that applies                              | Pipeline rollback runs |
| ------------------------------------------------------------------------ | ---------------------------------------------------------- | ---------------------- |
| `Rolling_Deployment`, which has its own **Manual Intervention** strategy | The step strategy, because it overrides the stage strategy | No                     |
| A step with no failure strategy of its own                               | The stage **Rollback Pipeline** strategy                   | Yes                    |

In the first row, the stage-level **Rollback Pipeline** strategy does not run, because the step-level strategy overrides it. This is expected behavior, not a failure of the stage strategy.

***

## Next steps

* [Define a failure strategy on stages and steps](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md): Configure automated failure handling strategies for pipeline stages and steps.
* [Abort pipeline, stage, or step](https://developer.harness.io/harness-platform/use-harness-platform/pipelines/failure-handling/abort-pipeline.md): Abort running executions instead of marking them as failed.

{% @harness-feedback/feedback module="harness-ai" pagePath="harness-ai/use-harness-platform/pipelines/failure-handling/mark-as-failed-pipeline" %}
