Publish Bitbucket Server PR

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

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

Description

Publishes a pull request on Bitbucket Server with specified title, description, and branch details.

Input Schema

PropertyTypeDescriptionRequired
titlestringThe title for the pull request
tokenstringThe token to use for authorization to BitBucket Server
repoUrlstringRepository Location
reviewersarrayThe usernames of reviewers that will be added to the pull request
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 PR from a feature branch with reviewers

Creates a pull request from a feature branch to main and adds reviewers. Logs the PR URL using debug:log.

Copy
steps:
  - id: create-pr
    action: publish:bitbucketServer:pull-request
    input:
      repoUrl: bitbucketServer?host=${{ parameters.host }}&project=${{ parameters.projectKey }}&repo=${{ parameters.repoSlug }}
      title: Add ${{ parameters.componentId }} scaffold
      description: Scaffolded initial code and CI configuration.
      targetBranch: main
      sourceBranch: feature/${{ parameters.componentId }}-scaffold
      reviewers: ${{ parameters.reviewers }}

  - id: log-pr-url
    action: debug:log
    input:
      message: Created PR at ${{ steps.create-pr.output.pullRequestUrl }}

Hotfix PR to a release branch with service token and author

Opens a hotfix pull request to a release branch using an explicit token and author fields. Use this when the scaffolder needs to authenticate to Bitbucket Server with a service account.

Copy
steps:
  - id: create-hotfix-pr
    action: publish:bitbucketServer:pull-request
    input:
      repoUrl: bitbucketServer?host=bitbucket.acme.corp&project=ORDERS&repo=order-service
      title: Hotfix prevent NPE in payment capture
      description: Backports null check for payment capture to release branch.
      targetBranch: release/2.1
      sourceBranch: hotfix/payment-capture-npe
      reviewers:
        - qauser
        - release-manager
      token: ${{ secrets.bitbucket_token }}
      gitAuthorName: Backstage Bot
      gitAuthorEmail: backstage-bot@acme.corp

Minimal PR using repository default target branch

Creates a pull request with only the required fields. Bitbucket Server uses the repository default branch as the target when targetBranch is omitted.

Copy
steps:
  - id: create-pr-minimal
    action: publish:bitbucketServer:pull-request
    input:
      repoUrl: bitbucketServer?host=${{ parameters.host }}&project=PLAT&repo=search-service
      title: Initial scaffold for search-service
      sourceBranch: feature/search-service-bootstrap

PR with multi-line description and JIRA references

Opens a pull request with a structured, multi-line description including JIRA references and checklist items.

Copy
steps:
  - id: create-detailed-pr
    action: publish:bitbucketServer:pull-request
    input:
      repoUrl: bitbucketServer?host=bitbucket.acme.corp&project=PLAT&repo=payments-service
      title: "[PLAT-4821] Add metrics and dashboards"
      description: |
        Implements service metrics and Grafana dashboards.
        - JIRA: https://jira.acme.corp/browse/PLAT-4821
        - Adds Prometheus counters and histograms
        - Updates alerts and SLOs
      targetBranch: develop
      sourceBranch: feature/plat-4821-metrics
      reviewers:
        - jdoe
        - asmith
        - opsuser

Environment-specific PR with parameterized branch and reviewers

Creates a pull request to promote environment configuration changes. The branch name and reviewers are provided by template parameters, and the PR URL is logged with debug:log.

Copy
steps:
  - id: create-env-pr
    action: publish:bitbucketServer:pull-request
    input:
      repoUrl: bitbucketServer?host=${{ parameters.host }}&project=PLAT&repo=platform-configs
      title: Promote ${{ parameters.environment }} configuration updates
      description: Automated config update for ${{ parameters.environment }} environment.
      targetBranch: ${{ parameters.targetBranch }}
      sourceBranch: env/${{ parameters.environment }}/config-update
      reviewers: ${{ parameters.approvers }}

  - id: log-pr
    action: debug:log
    input:
      message: Environment PR: ${{ steps.create-env-pr.output.pullRequestUrl }}