How to fix Merge request cannot be merged: pipeline failed in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025· 382 views

This GitLab error occurs when a merge request is blocked because the CI/CD pipeline has failed, been canceled, or hasn't run. To resolve it, fix the failing pipeline jobs, re-run the pipeline, or adjust the project's merge settings if appropriate.

Quick fix

Fixes Merge request cannot be merged: pipeline failed

# Example pipeline view:
✓ build        passed
✓ lint         passed
✗ test         failed (exit code 1)
○ deploy       skipped
  1. Check which pipeline jobs failed
  2. Fix the failing job and push a new commit
  3. Retry failed jobs or re-run the pipeline
  4. Validate your .gitlab-ci.yml configuration
git — error
# Example pipeline view:
✓ build passed
✓ lint passed
✗ test failed (exit code 1)
○ deploy skipped
Merge request cannot be merged: pipeline failed

What this error means

This error appears in GitLab when you attempt to merge a merge request, but the project's settings require a successful pipeline before merging can proceed. GitLab is blocking the merge because the associated CI/CD pipeline either failed, was canceled, or doesn't exist at all. The "Pipelines must succeed" setting in GitLab enforces that all CI/CD jobs pass before code can be merged into the target branch. This is a safety mechanism to prevent broken code from entering protected branches like main or master. There are several pipeline types that can trigger this block: merge request pipelines, merged results pipelines, merge train pipelines, or branch pipelines. When any of these fail or are canceled, GitLab prevents the merge to protect the integrity of your codebase.

Typical symptoms

  • Merge button is grayed out with 'pipeline failed' message
  • GitLab shows 'Merge blocked: pipeline must succeed'
  • Unable to merge despite code review approval
  • Merge request status shows a red X next to the pipeline
  • CI/CD jobs show as failed or canceled in the merge request
  • Merge train rejects the merge request
  • 'Auto-merge' cannot be enabled due to pipeline status
  • Merge request shows 'Checking pipeline status' indefinitely

Common causes

  1. One or more CI/CD jobs failed during the pipeline run
  2. Pipeline was manually canceled before completion
  3. Invalid or broken .gitlab-ci.yml configuration syntax
  4. No pipeline exists but 'Pipelines must succeed' setting is enabled
  5. Merge request pipeline failed while branch pipeline succeeded (or vice versa)
  6. Pipeline timed out due to long-running jobs
  7. External service dependency failure (Docker registry, npm, etc.)
  8. Resource constraints causing job failures
  9. Flaky tests producing intermittent failures
  10. Merge train pipeline conflict with other merge requests

How to fix "Merge request cannot be merged: pipeline failed"

1Check which pipeline jobs failed

First, identify which specific jobs caused the pipeline to fail:

1. Navigate to your merge request in GitLab
2. Click on the Pipelines tab
3. Click on the failed pipeline (shown with a red X)
4. Review the job list to find which jobs failed

text
# Example pipeline view:
✓ build        passed
✓ lint         passed
✗ test         failed (exit code 1)
○ deploy       skipped

Click on the failed job to view its logs and understand the failure reason.

2Fix the failing job and push a new commit

If the pipeline failure is due to actual code issues, fix them and push:

bash
# View the failing tests or issues locally first
npm test
# or
pytest
# or
make test

# After fixing the issues
git add .
git commit -m "fix: resolve failing tests"
git push origin your-branch

This triggers a new pipeline automatically. Common fixes include:
- Fixing failing unit tests
- Resolving linting errors
- Updating dependencies with security vulnerabilities
- Fixing compilation errors

3Retry failed jobs or re-run the pipeline

If the failure was due to a transient issue (network timeout, flaky test, resource exhaustion), retry the failed jobs:

Retry individual failed jobs:
1. Go to the failed pipeline
2. Click on the failed job
3. Click Retry button in the top right

Re-run the entire pipeline:
1. Navigate to the merge request
2. Go to the Pipelines tab
3. Click Run pipeline button

You can also use GitLab quick actions in a comment:

text
/rebase

This rebases the branch and triggers a new pipeline.

4Validate your .gitlab-ci.yml configuration

Invalid CI/CD configuration causes immediate pipeline failures. Validate your configuration:

Using the GitLab CI Lint tool:
1. Navigate to Build > Pipeline editor in your project
2. Click Validate tab
3. Paste your .gitlab-ci.yml content
4. Check for syntax errors

Common configuration issues:

yaml
# Wrong: Invalid YAML syntax (tabs instead of spaces)
test:
	script: npm test  # Tab character - use spaces!

# Correct:
test:
  script: npm test
yaml
# Wrong: Missing required 'script' keyword
test:
  - npm test

# Correct:
test:
  script:
    - npm test

From the command line:

bash
# Use the GitLab CI Lint API
curl --header "PRIVATE-TOKEN: <your_token>" \
  "https://gitlab.com/api/v4/ci/lint" \
  --form "content=@.gitlab-ci.yml"
5Handle 'Pipelines must succeed' with no pipeline

If your project has "Pipelines must succeed" enabled but no pipeline is configured, you have two options:

Option 1: Add a minimal pipeline
Create a .gitlab-ci.yml file:

yaml
# Minimal passing pipeline
stages:
  - test

placeholder:
  stage: test
  script:
    - echo "Pipeline passed"

Option 2: Disable the setting (if appropriate)
1. Navigate to Settings > Merge requests
2. Under "Merge checks", find "Pipelines must succeed"
3. Uncheck the option
4. Click Save changes

Note: Disabling this setting removes an important safety check. Only do this if you have other mechanisms to ensure code quality.

6Resolve merge request vs branch pipeline conflicts

When both merge request pipelines and branch pipelines run, GitLab only checks merge request pipelines for the "must succeed" requirement:

Symptoms:
- Branch pipeline shows green/passed
- Merge request still blocked
- Duplicate pipelines appearing

Solution: Use workflow:rules to prevent duplicate pipelines:

yaml
workflow:
  rules:
    # Run pipeline for merge requests
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    # Run pipeline for default branch
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    # Run pipeline for tags
    - if: $CI_COMMIT_TAG

stages:
  - test
  - build

test:
  stage: test
  script:
    - npm test

This ensures only one pipeline type runs, avoiding confusion about which status matters.

7Handle merge train pipeline failures

If using merge trains and the merge train pipeline fails:

Re-add to merge train:
1. Ensure your merge request pipeline is passing
2. Use the quick action in a comment:

text
/merge

Or click Start merge train / Add to merge train button.

Check for merge conflicts with other MRs:
Merge trains run merged results pipelines. If your MR conflicts with another MR already in the train, the pipeline may fail.

bash
# Rebase onto the latest target branch
git fetch origin main
git rebase origin/main
git push --force-with-lease origin your-branch

Note: The merge train pipeline tests your changes merged with all MRs ahead of yours in the queue. A failure might not be from your code alone.

8Close and reopen the merge request if status is stuck

Sometimes GitLab cannot retrieve the pipeline status correctly, especially if:
- The MR was created, closed, modified, then reopened
- There were connectivity issues during pipeline execution
- The GitLab Runner had issues reporting status

Fix by refreshing the MR state:
1. Close the merge request
2. Reopen it immediately
3. The pipeline status should now be retrieved correctly

Alternative: Trigger a new pipeline:

bash
# Create an empty commit to trigger a new pipeline
git commit --allow-empty -m "chore: trigger pipeline"
git push origin your-branch

This forces GitLab to run a fresh pipeline and update the status.

Advanced notes

### Understanding GitLab Pipeline Types

GitLab has several pipeline types that can affect merge eligibility:

| Pipeline Type | Trigger | Checks |
|--------------|---------|--------|
| Branch pipeline | Push to any branch | CI_COMMIT_BRANCH |
| Merge request pipeline | MR created/updated | CI_MERGE_REQUEST_IID |
| Merged results pipeline | Simulates merged code | CI_MERGE_REQUEST_EVENT_TYPE |
| Merge train pipeline | Adding to merge train | CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" |

### Merged Results Pipelines

These pipelines test what the result of merging would look like, not just your branch:

yaml
# Enable merged results pipelines
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
      when: always

They catch integration issues before actual merge occurs.

### Skipping Pipelines (Use Carefully)

In emergencies, maintainers can skip the pipeline requirement:

1. Project maintainers with "Allowed to merge" permissions can sometimes override
2. Using the `[skip ci]` commit message skips the pipeline entirely:

bash
git commit -m "docs: update README [skip ci]"

Warning: This bypasses safety checks and should only be used for documentation-only changes.

### Pipeline Timeout Issues

Long-running pipelines can time out, causing failures:

yaml
# Increase job timeout
test:
  script:
    - npm test
  timeout: 2h  # Default is 1 hour

# Or set globally in .gitlab-ci.yml
default:
  timeout: 2h

### Flaky Test Handling

For intermittently failing tests, GitLab offers retry configuration:

yaml
test:
  script:
    - npm test
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - script_failure  # Retry on test failures

### Protected Branch Settings

Pipeline requirements often apply only to protected branches. Check your settings:

1. Go to Settings > Repository > Protected branches
2. Review which branches require passing pipelines
3. Adjust rules as needed for your workflow

### Auto-merge (Merge When Pipeline Succeeds)

Instead of waiting for pipelines, enable auto-merge:

1. Click Set to auto-merge on the merge request
2. The MR automatically merges when the pipeline passes

This is useful for merge trains or long-running pipelines.

Frequently asked questions

What does "Merge request cannot be merged: pipeline failed" mean?
This error appears in GitLab when you attempt to merge a merge request, but the project's settings require a successful pipeline before merging can proceed. GitLab is blocking the merge because the associated CI/CD pipeline either failed, was canceled, or doesn't exist at all. The "Pipelines must succeed" setting in GitLab enforces that all CI/CD jobs pass before code can be merged into the target branch.
How do I fix "Merge request cannot be merged: pipeline failed"?
This GitLab error occurs when a merge request is blocked because the CI/CD pipeline has failed, been canceled, or hasn't run. To resolve it, fix the failing pipeline jobs, re-run the pipeline, or adjust the project's merge settings if appropriate.
What causes "Merge request cannot be merged: pipeline failed"?
One or more CI/CD jobs failed during the pipeline run Pipeline was manually canceled before completion Invalid or broken .gitlab-ci.yml configuration syntax
Is the "Merge request cannot be merged: pipeline failed" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading