Resolve issues automatically when users push code

This page is about transitioning issues in the Bitbucket Cloud issue tracker. If you have Bitbucket Cloud integrated with JIRA Software, then you can use Smart Commits instead.

You can configure Bitbucket Cloud to resolve Bitbucket Cloud tickets automatically when people push updates through to your Bitbucket Cloud repository.  They can specify commands and issues in commit messages, like this:

hg commit -m "fixes #6, resolve ticket #5 and see ticket #9 and ticket #5 in the tracker"

On Bitbucket, the commit message appears with links to each issue:

When you transition an issue with a commit message, the system cross-references the commit from the issue:

If you enabled an issue tracker on your repository after August 2012, Bitbucket adds the  Issues hook automatically for you when you enable the Issue Tracker.  Older repositories with older issue trackers may or may not have this hook.  You can check if this hook exists for a repository by going to the Hooks tab in the repository settings:

Adding the Issue Hook Manually

You only need to perform this procedure if your repository has the issue tracker enabled but does not have an Issue issue on the repository. 

You must have administrative access on a repository to add this hook.
  1. Go to the repository's settings.
  2. Click Hooks in the left-hand navigation.
    The hook page appears.
  3. Select the Issues hook from the Hook dropdown.
  4. Click Add hook.
    A new section appears for the Issues hook.

  5. Press Save.
    The page remains unchanged but the hook is started.

Including Issues in a Commit Message

To link commit to an issue from a commit message, include an command-issue pair somewhere in your commit message. This pair takes the following format:
<command> <issue id>

You can link to a single issue or multiple issues.  The <issue id> can take an of the following forms:

issue #4711
bug #4711
ticket #4711

You should always include the # (pound sign or hash mark) if you want to ensure that links back to the issue resolve.  If you omit the # (pound sign or hash mark), links from a changeset do not resolve.

Each action supports multiple <command> keywords. The following table lists the actions you can perform through a commit and the acceptable commands for that action.  All the keywords are case insensitive. So, for example, both close and Close work to close an issue.

Action Command Keyword Examples
resolve an issue
  • close
  • closes
  • closed
  • closing
  • fix
  • fixed
  • fixes
  • fixing
  • resolve
  • resolves
  • resolved
  • resolving

close #845

fix bug #89

fixes issue 746

resolving #3117
reopen an issue
  • reopen
  • reopens
  • reopening
reopen #746

reopening #78

mark an issue on hold
  • hold
  • holds
  • holding
holds #123
mark an issue wontfix
  • wontfix
wontfix #12
mark an issue invalid
  • invalidate
  • invalidates
  • invalidated
  • invalidating
invalidates #45
link to a changeset for the issue
  • addresses
  • re
  • references
  • ref
  • refs
  • see
re bug #55

see #34 and #456

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport