Smart Commit を使用する

When you manage your project's repositories in Bitbucket or GitHub, or use Fisheye to browse and search your repositories, you can process your Jira work items using special commands, called Smart Commits, in your commit messages.

以下のことが可能です。

  • comment on work itemss

  • record time tracking information against work items

  • transition work items to any status defined in the Jira project's workflow.

ソフトウェアのレビューに Crucible を使用する場合、ほかにもアクションを利用できます。Crucible ドキュメントの「Smart Commit を使用する」を参照してください。

スマート コミット コマンドは 1 行に収める必要があります (例えば、コマンドではキャリッジ リターンを使用できません) が、詳細な例で示されるように、同じ行に複数のコマンドを追加できます。1 行に複数のコマンドを入れる例は次を参照してください。

スマートコミット コマンド

スマート コミット メッセージの基本的な構文は次のとおりです。

<ignored text> <WORK_ITEM_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS>

Any text between the work item key and the command is ignored.

スマート コミット メッセージでは次の 3 つのコマンドを使用できます。

  • comment

  • time

  • transition

コメント

説明

Adds a comment to a Jira work item.

構文

<ignored text> <WORK_ITEM_KEY> <ignored text> #comment <comment_string>

JRA-34 #comment corrected indent work item

注意

The committer's email address must match the email address of a single Jira user with permission to comment on work items in that particular project

GitHub 使用時に関する詳細

  • The email address in Github must match the email address of a single Jira user with permission to comment on work items in that particular project

  • スマート コミットが正しく機能するためには、GitHub で [メールアドレスを非公開にする] のチェックをオフにします

時間

説明

Records time tracking information against an work item.

構文

<ignored text> <WORK_ITEM_KEY> <ignored text> #time <value>w <value>d <value>h <value>m <comment_string>

JRA-34 #time 1w 2d 4h 30m Total work logged

注意

This example records 1 week, 2 days, 4 hours and 30 minutes against the work item, and adds the comment 'Total work logged' in the Work Log tab of the work item.

  • wdh および m の値には、小数も使用できます。

  • コメントは、comment コマンドを使用しなくても自動的に追加されます。

  • The committer's email address must match the email address of a single Jira user with permission to log work on an work item.

  • システム管理者が

    Jira インスタンス

ワークフローのトランジション

説明

Transitions a Jira work item to a particular workflow state.

構文

<ignored text> <WORK_ITEM_KEY> <ignored text> #<transition_name> #comment <comment_string>

JRA-090 #close #comment Fixed this today

注意

This example executes the close work item workflow transition for the work item and adds the comment 'Fixed this today' to the work item. 

この構文にはいくつかの例外があります。

  • Jira 管理者がコメントを必須フィールドに設定している場合、コマンドに #comment を追加しないでください。

  • その他のいずれかのフィールドが必須に設定されている場合、トランジション コマンドは通知なしで失敗します。

Smart Commit と併用可能なカスタムコマンドを確認するには、

Jira work item and looking at its available workflow transitions:

  1. Open a work item in the project.

  2. Select View Workflow (near the work item's Status).

Smart Commit は、最初のスペースの前のトランジション名の部分のみを考慮します。したがって、finish work などのトランジション名の場合、#finish と指定すれば十分です。トランジション名に曖昧さが含まれる場合、スペースの代わりにハイフンを使用する必要があります。たとえば、#finish-work などです。

次のように、ワークフローに2つの有効なトランジションがある場合:

  • Start Progress

  • Start Review

アクション #start を含むスマート コミットは 2 つのトランジションのいずれかを意味することになるため、曖昧であると見なされます。これら 2 つのトランジションの 1 つを指定するには、#start-review または #start-progress のいずれかを使用して、使用したいトランジションを完全修飾します。

  • When you resolve a work item with the #resolve command, you cannot set the Resolution field with Smart Commits.

  • コミット実施者のメール アドレスは、対象のプロジェクトでの課題へのコメント追加権限を持つ

    Jira

    user with the appropriate project permissions to transition work items.

高度な例

Multiple commands on a single work item

構文

<WORK_ITEM_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS>

コミット メッセージ

JRA-123 #time 2d 5h #comment Task completed ahead of schedule #resolve

結果

Logs 2 days and 5 hours of work against work item JRA-123, adds the comment 'Task completed ahead of schedule', and resolves the work item.

Multiple commands over multiple lines on a single work item

構文

<WORK_ITEM_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS>

コミット メッセージ

JRA-123 #comment Imagine that this is a really, and I 
mean really, long comment #time 2d 5h

結果

Adds the comment 'Imagine that this is a really, and I', but drops the rest of the comment. The work time of 2 days and 5 hours is not logged against the work item because there is no work item key for the #time command in the second line. That is, each line in the commit message must conform to the Smart Commit syntax.

この例では、以下のように設定すると、想定通りに動作します。

JRA-123 #comment Imagine that this is a really, and I mean really, long comment 
JRA-123 #time 2d 5h

A single command on multiple work items

構文

<WORK_ITEM_KEY1> <WORK_ITEM_KEY2> <WORK_ITEM_KEY3> #<COMMAND> <optional COMMAND_ARGUMENTS> etc

コミット メッセージ

JRA-123 JRA-234 JRA-345 #resolve

結果

Resolves work items JRA-123, JRA-234 and JRA-345.

Multiple work item keys must be separated by whitespace or commas.

Multiple commands on multiple work items

構文

<WORK_ITEM_KEY1> <WORK_ITEM_KEY2> ... <WORK_ITEM_KEYn> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS>

コミット メッセージ

JRA-123 JRA-234 JRA-345 #resolve #time 2d 5h #comment Task completed ahead of schedule

結果

Logs 2 days and 5 hours of work against work items JRA-123, JRA-234 and JRA-345, adds the comment
'Task completed ahead of schedule' to all three work items, and resolves all three work items.

Multiple work item keys must be separated by whitespace or commas.

Smart Commit の活用

Jira のインスタンスでスマート コミットを使用できるようにするのは簡単です。

ツール

接続の手順

Bitbucket Cloud

まず、Jira と Bitbucket アカウントをリンクします。「Jira Cloud と Bitbucket Cloud の接続」を参照してください。

次に、Jira でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。

GitHub

まず、Jira と GitHub アカウントをリンクします。「Jira Cloud と GitHub の接続」を参照してください。

次に、Jira でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。

Bitbucket Data Center

Jira と Bitbucket Data Center 間のアプリケーション リンクを作成します。「Bitbucket Data Center を Jira とリンクする」を参照してください。

次に、Jira でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。

Fisheye

Jira と Fisheye 間のアプリケーション リンクを作成します。「別のアプリケーションへのリンク」を参照してください。

次に、Jira でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。

Crucible

Jira と Crucible 間のアプリケーション リンクを作成します。「別のアプリケーションへのリンク」を参照してください。

次に、Jira でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。

注意

  • Smart Commits only support the default Jira work item key format. This format is two or more uppercase letters, followed by a hyphen and the work item number, for example JRA-123. 

  • A DVCS such as Git includes a user's email address in the commit data. Users configure this email address in their local system. Smart Commits requires that this email address match exactly one email address in the Jira user base. If the email address matches multiple users in Jira, or the user does not have permissions for the requested action, the Smart Commit action will fail. The commit itself will succeed however, and will show on the work item. Mismatched email addresses is a common reason why Smart Commits fail to work as expected. If a Smart Commit fails, Jira sends an email notification to either the Jira user, or to the DVCS user (if a Jira user can't be identified). In rare cases, Jira doesn't have either of these email addresses, and the Smart Commit fails silently.

 

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。