четверг, 1 августа 2013 г.

Smart commits with JIRA + BitBucket

The commands

There are three commands you can use in your commit message.

time Command
ISSUE_KEY #time <value>w <value>d <value>h <value>m  <comment_string> 
Records time tracking information against an issue.  The value must be a whole number. For example:
JRA-34 #time 1w 2d 4h 30m Total work logged
This example records 1 week, 2 days, 4hours and 30 minutes against an issue, and adds the comment 'Total work logged' in the Work Log tab of the issue.
For this command to work, your system administrator must have enabled time tracking on your JIRA instance.

comment Directive

ISSUE_KEY #comment <comment_string>
Records a comment against an issue.  For example:
JRA-34 #comment corrected indent issue
Adds the comment "corrected indent issue" to the issue.

<transition> Directive

ISSUE_KEY #<transition> <comment_string>
Transitions an issue to a particular workflow state.  For example:
JRA-090 #close Fixed this today
Executes the close issue workflow transition for an issue. This transition is in the default JIRA workflow.  The directive also adds the comment 'Fixed this today' to the issue. 
The available transition values depend on a project's workflow configuration. To view a project's workflow, log into JIRA and do the following:
  1. Open an issue in the project.
  2. Locate the Status field in the Details section.
  3. Click the View Workflow link provided.
The smart commit works on the transition prefixes. This means if you have transition names with spaces, such as finish work, then specifying #finish is sufficient. Hyphens replace spaces: #finish-work also matches.
Issue transitions work only if there is no ambiguity in valid workflow transitions. Suppose a workflow has two valid transitions:
  • Start Progress
  • Start Review
A smart commit with action #start is ambiguous because it could mean either of the two transitions. To execute one of these two transitions, fully qualify the transition you want by specifying either #start-review or #start-progress.
When you resolve an issue with the #resolve directive, you cannot set the Resolution field via smart commits.

Advanced Examples

A single action on a single issue
Record 2 days and 5 hours of work against issue JRA-123:
JRA-123 #time 2d 5h

Multiple actions on a single issue
<ISSUE_KEY> #<CMD_1> <optional CMD1_PARAMETERS> #<CMD_2> <optional CMD2_PARAMETERS> ... #<CMD_n> <optional CMDn_PARAMETERS>
Log 2 days and 5 hours of work against issue JRA-123, add the comment 'Task completed ahead of schedule' and resolve the issue:
JRA-123 #time 2d 5h #comment Task completed ahead of schedule #resolve

Aa single action on multiple issues
Resolve issues JRA-123, JRA-234 and JRA-345:
JRA-123 JRA-234 JRA-345 #resolve

Multiple actions on multiple issues
<ISSUE_KEY1> <ISSUE_KEY2> ... <ISSUE_KEYn> #<CMD_1> <optional CMD1_PARAMETERS> #<CMD_2> <optional CMD2_PARAMETERS> ... #<CMD_n> <optional CMDn_PARAMETERS>
Log 2 days and 5 hours of work against issues JRA-123, JRA-234 and JRA-345, add the comment 'Task completed ahead of schedule' to all three issues, and resolve all three issues.
JRA-123 JRA-234 JRA-345 #resolve #time 2d 5h #comment Task completed ahead of schedule