Publish Bitbucket Pull Request

Action ID: publish:bitbucketCloud:pull-request
NPM Package:

@backstage/plugin-scaffolder-backend-module-bitbucket-cloud

Description

Publishes a pull request to Bitbucket Cloud from a specified source branch to a target branch.

Input Schema

PropertyTypeDescriptionRequired
titlestringThe title for the pull request
tokenstringThe token to use for authorization to BitBucket Cloud
repoUrlstringRepository Location
descriptionstringThe description of the pull request
sourceBranchstringBranch of repository to copy changes from
targetBranchstring-
gitAuthorNamestring-
gitAuthorEmailstring-

Output Schema

PropertyTypeDescriptionRequired
pullRequestUrlstringA URL to the pull request with the provider

Usage Examples

Create a feature branch PR to main

Opens a pull request from a feature branch to main with a concise description. It then logs the PR URL using debug:log.

Copy
steps:
  - id: create_feature_pr
    action: publish:bitbucketCloud:pull-request
    input:
      repoUrl: bitbucket.org?workspace=acme&project=PAY&repo=payments-service
      title: "feat: add customer credit limit API"
      description: |-
        Adds /credit-limits endpoints and docs.
        See JIRA PAY-1423 for details.
      sourceBranch: feature/pay-1423-credit-limits
      targetBranch: main

  - id: log_feature_pr
    action: debug:log
    input:
      message: "Created PR at ${{ steps.create_feature_pr.output.pullRequestUrl }}"

Hotfix PR into a release branch with explicit credentials

Creates a PR from a hotfix branch into a release branch, providing a token and author info for auditability. It then logs the PR URL using debug:log.

Copy
steps:
  - id: hotfix_pr
    action: publish:bitbucketCloud:pull-request
    input:
      repoUrl: bitbucket.org?workspace=acme&project=WEB&repo=frontend
      title: "fix: revert broken navbar in 2.8.1"
      description: "Reverts regression introduced by abc123. Urgent patch for 2.8.x."
      sourceBranch: hotfix/2.8.1-navbar-revert
      targetBranch: release/2.8
      token: ${{ secrets.bitbucketToken }}
      gitAuthorName: "CI Bot"
      gitAuthorEmail: "[email protected]"

  - id: log_hotfix_pr
    action: debug:log
    input:
      message: "PR created: ${{ steps.hotfix_pr.output.pullRequestUrl }}"

Parameterized PR using the repository default branch

Opens a PR without specifying targetBranch so Bitbucket uses the repository default branch. Branch names and titles are parameterized, and the PR URL is logged via debug:log.

Copy
steps:
  - id: param_pr
    action: publish:bitbucketCloud:pull-request
    input:
      repoUrl: bitbucket.org?workspace=acme&project=PLAT&repo=${{ parameters.repoName }}
      title: "chore: update Helm chart for ${{ parameters.serviceName }}"
      description: |-
        Updates Helm values for ${{ parameters.serviceName }}.
        Change ref: ${{ parameters.ticketId }}.
      sourceBranch: feature/${{ parameters.ticketId }}-helm-update

  - id: log_param_pr
    action: debug:log
    input:
      message: "Opened PR: ${{ steps.param_pr.output.pullRequestUrl }}"

Monorepo automation PR to develop

Creates a PR from an automation branch to develop in a monorepo, typically after automated changes land on the source branch. It logs the PR URL using debug:log.

Copy
steps:
  - id: monorepo_pr
    action: publish:bitbucketCloud:pull-request
    input:
      repoUrl: bitbucket.org?workspace=acme&project=PLAT&repo=platform-config
      title: "chore: bump Node.js to 18.x across services"
      description: |-
        Automated update of Node runtime and Dockerfiles.
        Trigger: template run ${{ parameters.runId }}.
      sourceBranch: automation/node18-bump
      targetBranch: develop
      token: ${{ secrets.bitbucketToken }}

  - id: log_monorepo_pr
    action: debug:log
    input:
      message: "PR: ${{ steps.monorepo_pr.output.pullRequestUrl }}"

Documentation updates PR with custom author

Opens a PR from a docs branch to main for documentation updates, setting an explicit author and using a token passed as a parameter. It logs the PR URL with debug:log.

Copy
steps:
  - id: docs_pr
    action: publish:bitbucketCloud:pull-request
    input:
      repoUrl: bitbucket.org?workspace=acme&project=DOCS&repo=engineering-handbook
      title: "docs: Q4 updates to service ownership guidelines"
      description: "Refreshes guidelines and adds architecture review checklist."
      sourceBranch: docs/q4-service-ownership
      targetBranch: main
      token: ${{ parameters.bitbucketToken }}
      gitAuthorName: "Docs Automation"
      gitAuthorEmail: "[email protected]"

  - id: log_docs_pr
    action: debug:log
    input:
      message: "Docs PR: ${{ steps.docs_pr.output.pullRequestUrl }}"