Pipelines deployments are paused for deploying from non-permitted branch

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

This article addresses scenarios where a pipeline deployment is paused due to deployment restrictions on specific branches. Although pipeline runs from non-permitted branches are typically paused as expected, there are instances where pipeline deployments initiated directly from commits on allowed branches encounter failures.

(Auto-migrated image: description temporarily unavailable)

Cause

Bitbucket pipelines offer the capability to run a pipeline job directly from the commits page.

(Auto-migrated image: description temporarily unavailable)

When one selects the "Run Pipeline" option, the pipeline undergoes checks for deployment conditions. Eg: deployment branch restrictions. Even if the commit is associated with an allowed branch, initiating pipeline run directly from a commit will result in the pipeline being paused. In such scenarios, the pipeline attempts to perform a checkout of the specific commit rather than a git branch. This leads to a "detached HEAD" state, where the working directory is not associated with any branch. As a result, the pipeline validation fails for the allowed branch, causing the error.

Solution

To execute a pipeline deployment for a specified commit with deployment branch restrictions enabled, one option is to trigger a custom pipeline from an appropriate branch. Following this, a reset of the required commit should be performed in the pipeline step. This sequence ensures that the pipeline deployment executes on the required commit without any issues.

For illustration, consider the following sample pipeline configuration:

1 2 3 4 5 6 7 8 9 10 pipelines: custom: run-test-for-environment: - variables: - name: commithash default: HEAD #if no values provided it will be resetting to HEAD commit of a branch - step: script: - git reset --hard ${commithash} - echo "build is running"

Steps:

  1. In Bitbucket, choose a repo and go to Branches.

  2. Choose the branch you want to run a custom pipeline for.

  3. Click (...), and select Run pipeline for a branch.

    (Auto-migrated image: description temporarily unavailable)
  4. Choose the custom pipeline (eg: run-test-for-environment), enter the commit hash details and click Run:

    (Auto-migrated image: description temporarily unavailable)

By following this sequence, the pipeline deployment will be executed successfully without encountering errors related to detached HEAD states or validation issues.

(Auto-migrated image: description temporarily unavailable)

If the above instructions do not assist in resolving the issue, please raise a support ticket or raise a community support ticket for further assistance with this.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.