Merge pull request

Connector functions are a new addition to Slack automations. We recommend understanding the systems and APIs you're integrating with before setup.

Facts

Merge pull request

Schema: Connectors.AtlassianBitbucket.functions.MergePullRequest
Service: Bitbucket

Input parameters

Required parameters
Determines whether this connector will use the credentials of the user starting the workflow or the credentials configured by an app collaborator. See the Authentication section on this page for details.

Example
{ credential_source: "END_USER" }
The ID of the workspace containing the repository where the pull request can be found

Example
"ABC12345-changeme"
The ID of the repository containing the pull request you wish to merge

Example
"DEF54321-changeme"
The ID of the pull request you wish to merge

Example
"ABC123-changeme"
Optional parameters
A message added to the pull request merge action
If true, the source branch will be closed once the merge is complete
The merge strategy to use

Output parameters

Required parameters
Response code
Bitbucket workspace ID
Repository ID
Pull request ID

Authentication

A connector's access token property specifies how the connector handles authentication.

This connector only supports using the credentials of the user running the workflow, so the credential_source of this connector's access token parameter must be set to "END_USER".

End-user authentication

user Workflows that include a connector function relying on end-user authentication can can only be started with a link trigger.

bitbucket_access_token: {
    credential_source: "END_USER"
}

End-user experience: User will be prompted to link their external account via OAuth when they first start the workflow that contains this connector.

Developer experience: Developer does not have to implement authentication in app.

How to use

First, import Connectors from deno-slack-hub into your project's import_map.json file, like this:

{
  "imports": {
    "deno-slack-hub/": "https://deno.land/x/deno_slack_hub@2.2.0/",
    "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.14.2/",
    "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.8.0/",
  }
}

Next, import Connectors at the top of your workflow's definition file:

// my_workflow_file.ts
import { Connectors } from "deno-slack-hub/mod.ts";

Finally, add the connector as a step in your workflow just like you would a built-in Slack function.

SomeWorkflow.addStep(
  Connectors.AtlassianBitbucket.functions.MergePullRequest, {
    // The ID of the workspace containing the repository where the pull request can be found
    workspace: "ABC12345-changeme",

    // The ID of the repository containing the pull request you wish to merge
    repo_slug: "DEF54321-changeme",

    // The ID of the pull request you wish to merge
    pull_request_id: "ABC123-changeme",

    // (Optional) A message added to the pull request merge action
    // message: "Fixes #123",

    // (Optional) If true, the source branch will be closed once the merge is complete
    // close_source_branch: true,

    // (Optional) The merge strategy to use
    // merge_strategy: "merge_commit",

    bitbucket_access_token: { credential_source: "END_USER" }
  }
);

🧙🏼 Your admin may need to approve the connector first. If your workspace has been configured to only allow admin-approved apps, the CLI will prompt you to send an admin approval request the first time you try to use a connector that hasn't been approved by an admin yet. While waiting for admin approval, the CLI may report an error like this:

Workflow function... is referring to an unknown step output parameter...

You can safely ignore this error; it will go away as soon as your workspace admin approves your request to use the connector.