Using Smart Commits in Bitbucket Server
Smart Commit commands
The basic command line syntax for a smart commit message is:
<ignored text> <ISSUE_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS>
Any text between the issue key and the smart commit command is ignored.
There are three smart commit commands you can use in your commit messages:
Comment
Description | Adds a comment to a JIRA Software issue. |
---|---|
Syntax | <ignored text> ISSUE_KEY <ignored text> #comment <comment_string> |
Example | JRA-34 #comment corrected indent issue |
Notes |
|
Time
Description | Records time tracking information against an issue. |
---|---|
Syntax | <ignored text> ISSUE_KEY <ignored text> #time <value>w <value>d <value>h <value>m <comment_string> |
Example | JRA-34 #time 1w 2d 4h 30m Total work logged |
Notes | This example records 1 week, 2 days, 4hours and 30 minutes against the issue, and adds the comment '
|
Workflow transitions
Description | Transitions a JIRA Software issue to a particular workflow state. |
---|---|
Syntax | <ignored text> ISSUE_KEY <ignored text> #<transition_name> <comment_string> |
Example | JRA-090 #close Fixed this today |
Notes | This example executes the close issue workflow transition for the issue and adds the comment ' You can see the custom commands available for use with smart commits by visiting the JIRA Software issue and seeing its available workflow transitions:
The smart commit only considers the part of a transition name before the first space. So, for a transition name such as If a workflow has two valid transitions, such as:
A smart commit with the action
|
Advanced examples
Multiple commands over multiple lines on a single issue
Syntax | <ISSUE_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> |
---|---|
Commit message | JRA-123 #comment Imagine that this is a really, and I mean really, long comment #time 2d 5h |
Result | Adds the comment 'This is a really, and I' (but drops the rest of the comment) and logs 2 days and 5 hours of work against issue JRA-123. |
Multiple commands on a single issue
Syntax | <ISSUE_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> |
---|---|
Commit message | JRA-123 #time 2d 5h #comment Task completed ahead of schedule #resolve |
Result | Logs 2 days and 5 hours of work against issue JRA-123, adds the comment 'Task completed ahead of schedule', and resolves the issue. |
A single command on multiple issues
Syntax | <ISSUE_KEY1> <ISSUE_KEY2> <ISSUE_KEY3> #<COMMAND> <optional COMMAND_ARGUMENTS> etc |
---|---|
Commit message | JRA-123 JRA-234 JRA-345 #resolve |
Result | Resolves issues JRA-123, JRA-234 and JRA-345. Multiple issue keys must be separated by whitespace or commas. |
Multiple commands on multiple issues
Syntax | <ISSUE_KEY1> <ISSUE_KEY2> ... <ISSUE_KEYn> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> |
---|---|
Commit message | JRA-123 JRA-234 JRA-345 #resolve #time 2d 5h #comment Task completed ahead of schedule |
Result | Logs 2 days and 5 hours of work against issues JRA-123, JRA-234 and JRA-345, adds the comment Multiple issue keys must be separated by whitespace or commas. |
Get Smart Commits working
Smart Commits work with Bitbucket Server 4.2+ and JIRA Software Server 7.1+.
To get Smart Commits working for JIRA Software and Bitbucket Server:
- Create an application link between JIRA Software and Bitbucket Server. See Linking Bitbucket Server with JIRA.
- Enable smart commits in JIRA Software. See Enabling DVCS Smart Commits.
Some limitations of Smart Commits:
- Smart Commits only support the default JIRA Software issue key format (that is, two or more uppercase letters, followed by a hyphen and the issue number, for example BAM-123).
Smart Commits don't provide for field-level updates in JIRA Software issues.
Note that elevated access rights in JIRA Software Server can result from the way that Git (and Mercurial) allow commits to be attributed to a user other than the user pushing a change to the repository. If this seems like a risk for your situation, then you should consider disabling Smart Commits on the JIRA Software Server instance.