Bitbucket Data Center icon

Bitbucket Data Center

Interact with Bitbucket Data Center API

Overview

The Bitbucket Data Center node allows interaction with the Bitbucket Data Center API to manage various resources such as projects, repositories, pull requests, branches, commits, tags, files, users, issues, and webhooks. Specifically, for the Branch - Create operation, this node creates a new branch in a specified repository within a project. This is useful for automating version control workflows, such as creating feature branches or hotfix branches programmatically.

Practical example:
You can use this node to automatically create a new branch named "feature-xyz" starting from the "main" branch in a given repository when a certain event occurs (e.g., a Jira issue transitions to "In Progress"). This helps streamline development workflows by integrating branch creation into your automation pipelines.

Properties

Name Meaning
Authentication Method of authentication: either "Personal Access Token" or "Basic Auth".
Project The key of the project containing the repository where the branch will be created.
Branch Name The name of the new branch to create.
Start Point The branch or commit hash from which the new branch will start (default is "main").

Output

The output is a JSON array containing the response from the Bitbucket Data Center API after creating the branch. This typically includes details about the newly created branch such as its name, start point, and metadata returned by the API.

If the operation succeeds, the output JSON object represents the created branch resource. If an error occurs and "Continue On Fail" is enabled, the output will include an error message object instead.

The node does not output binary data.

Dependencies

  • Requires access to a Bitbucket Data Center instance.
  • Requires credentials configured in n8n for authentication, either via:
    • A Personal Access Token credential, or
    • Basic Authentication credential (username and password).
  • The node uses the Bitbucket Data Center REST API endpoints under /rest/branch-utils/1.0/projects/{projectKey}/repos/{repositorySlug}/branches.

Troubleshooting

  • Common issues:

    • Incorrect project key or repository slug: Ensure that the project and repository exist and the keys/slugs are correct.
    • Insufficient permissions: The API user must have permission to create branches in the target repository.
    • Invalid branch name or start point: The branch name must follow Bitbucket naming conventions; the start point must be a valid branch or commit hash.
    • Network or authentication errors: Verify that the server URL and credentials are correctly configured.
  • Error messages:

    • "Bitbucket Data Center API request failed: ..." indicates an API call failure. Check credentials, network connectivity, and API endpoint correctness.
    • "The operation "create" is not supported for resource "branch" would indicate a misconfiguration but should not occur if using the node properly.
    • If the node throws an error about missing parameters, ensure all required fields (Project, Repository, Branch Name, Start Point) are provided.

Links and References


Summary of the execute() method logic for Branch - Create:

  • Retrieves input data items.
  • For each item, reads parameters: project key, repository slug, branch name, start point, and authentication type.
  • Selects appropriate credentials based on authentication method.
  • Calls the Bitbucket Data Center API endpoint to create a branch:
    • POST to /rest/branch-utils/1.0/projects/{projectKey}/repos/{repositorySlug}/branches
    • Payload includes { name: branchName, startPoint: startPoint }.
  • Collects responses or errors per item.
  • Returns the aggregated results as JSON output.

Discussion