Draft pull request plugin

The Bitbucket draft pull request plugin allows you to label a pull request as a draft. While a pull request is marked as a draft, the merge button is not available.

Bitbucket pull request marked as draft using label and failing merge check

This is useful to signal that it is still a work in progress (WIP) - even if all other checks are passing, it is not ready to be merged yet.

This plugin supports the draft pull request workflow by:

  • Using a label to identify draft pull requests
  • Creating an extended check to prevent merging of draft pull requests
  • Optionally add the draft label to new pull requests automatically

The simplest configuration is:

import {const configure: (config: Config | (() => Config)) => voidconfigure} from "flowie.app"
import {const draftPullRequest: OptionsPlugin<DraftPullRequestOptions, false>
Support for draft pull requests
draftPullRequest
, const merge: OptionsPlugin<MergePluginOptions, false>merge} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): voidconfigure({ Config.plugins?: PluginDef<unknown>[] | undefinedplugins: [ // Use merge plugin to enforce merge checks function merge(): PluginDef<MergePluginOptions> (+2 overloads)merge(), function draftPullRequest(): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requests
draftPullRequest
(),
], })

Using the options:

function draftPullRequest(options: DraftPullRequestOptions): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requests
draftPullRequest
({
DraftPullRequestOptions.draftOnCreate?: RulesOr<boolean | undefined>
Adds the label automatically to the pull request on creation, marking it as a draft. Default: true
draftOnCreate
: false,
DraftPullRequestOptions.label?: LabelRef | undefined
Existing label from the schema to be used for marking the pull request as draft. Default: {name: "Draft"} and is created automatically if not present in the schema.
label
: {LabelRef.name: stringname: "WIP"},
DraftPullRequestOptions.title?: string | undefined
Title for the merge check. It supports markdown for formatting. Default: **No** work in progress
title
: "**No** draft",
})
Bitbucket pull request marked as draft/WIP using custom options and failing merge check

Options:

draftOnCreate - if true, it adds the label automatically to the pull request, marking it as a draft. Default: true

label - the label to use to mark the pull request as draft. If you specify a label, it must be defined in the label schema as well. Default: {name: "Draft"} and is created automatically if not present in the schema.

title - the title of the check. It supports markdown for formatting. Default: **No** work in progress

Draft as part of workflow

If you are using LabelSets to model workflow you can use them together by setting draft pull request as one of the possible values:

import {const configure: (config: Config | (() => Config)) => voidconfigure} from "flowie.app"
import {const draftPullRequest: OptionsPlugin<DraftPullRequestOptions, false>
Support for draft pull requests
draftPullRequest
} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): voidconfigure({
Config.labels?: {
    schema?: Array<Label>;
} | undefined
labels
: {
schema?: Label[] | undefinedschema: [ { BasicLabel.name: stringname: "Status",
LabelSet.values: (string | [string, LabelValueOptions & {
    valueColor?: Color;
}])[]
values
: [
["Draft", {LabelValueOptions.color?: Color | undefinedcolor: "Yellow300"}], "Ready to review", ["Ready to merge", {LabelValueOptions.color?: Color | undefinedcolor: "greenLight"}], ], }, ], }, Config.plugins?: PluginDef<unknown>[] | undefinedplugins: [ function draftPullRequest(options: DraftPullRequestOptions): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requests
draftPullRequest
({
DraftPullRequestOptions.label?: LabelRef | undefined
Existing label from the schema to be used for marking the pull request as draft. Default: {name: "Draft"} and is created automatically if not present in the schema.
label
: {LabelRef.name: stringname: "Status", LabelRef.value?: string | undefinedvalue: "Draft"},
}), ], })

Results in:

Bitbucket pull request marked as draft using label and failing merge check
Bitbucket pull request marked as draft using label and failing merge checkBitbucket pull request marked as draft using label and failing merge check