Process work items with smart commits
When you manage your project repositories in Bitbucket or GitHub, or use Fisheye to browse and search your repositories, you can process your Jira Software work items using special commands, called Smart Commits, in your commit messages.
以下のことが可能です。
comment on work items
record time tracking information against work items
transition work items to any status defined in the software project workflow.
ソフトウェアのレビューに Crucible を使用する場合、ほかにもアクションを利用できます。Crucible ドキュメントの「Smart Commit を使用する」を参照してください。
スマート コミット コマンドは 1 行に収める必要があります (コマンドでキャリッジ リターンを使用できません) が、1 つの行に複数のコマンドを追加できます。以下の例を参照してください。
スマートコミット コマンド
In smart commit commands, ‘issue’ refers to a work item. What is a work item?
スマート コミット メッセージの基本的な構文は次のとおりです。
<ignored text> <ISSUE_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 Software work item. |
---|---|
構文 |
|
例 | JRA-34 #comment corrected indent issue JRA-34 #comment: 修正済みのインデントの問題 |
注意 | The committer's email address must match the email address of a single Jira Software user with permission to comment on work items in that particular project. |
時間
説明 | Records time tracking information against a work item. |
---|---|
構文 |
|
例 | JRA-34 #time 1w 2d 4h 30m Total work logged 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 '
|
ワークフローのトランジション
説明 | Transitions a Jira Software work item to a particular workflow state. |
---|---|
構文 |
|
例 | JRA-090 #close #comment Fixed this today JRA-090 #close #comment 本日修正 |
注意 | This example executes the close work item workflow transition for the work item and adds the comment '
この構文にはいくつかの例外があります。
You can see the custom commands available for use with Smart Commits by visiting the Jira Software work item and looking at its available workflow transitions:
Smart Commit は、最初のスペースの前のトランジション名の部分のみを考慮します。したがって、 次のように、ワークフローに2つの有効なトランジションがある場合:
アクション
|
View development information on your Jira work items
To view linked development information in a Jira work item:
Navigate to the work item.
[開発] で、追加情報を表示する件のプル リクエスト、ブランチ、またはコミットの数を選択します。
高度な例
Multiple commands on a single work item
構文 | <ISSUE_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> <ISSUE_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 JRA-123 #time 2d 5h #comment 期限前にタスクを完了 #resolve |
結果 | Logs 2 days and 5 hours of work against work item JRA-123, adds the comment 'Task completed ahead of schedule', |
単一の課題に対して複数行にわたる複数のコマンド
構文 | <ISSUE_KEY> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> <ISSUE_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 JRA-123 #comment これがものすごく
mean really, long comment #time 2d 5h 長いコメントだとお考えください #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 # この例では、以下のように設定すると、想定通りに動作します。 JRA-123 #comment Imagine that this is a really, and I mean really, long comment JRA-123 #comment Imagine that this is a really, and I mean really, long comment
JRA-123 #time 2d 5h JRA-123 #time 2d 5h |
A single command on multiple work items
構文 | <ISSUE_KEY1> <ISSUE_KEY2> <ISSUE_KEY3> #<COMMAND> <optional COMMAND_ARGUMENTS> etc <ISSUE_KEY1> <ISSUE_KEY2> <ISSUE_KEY3> #<COMMAND> <optional COMMAND_ARGUMENTS> など |
---|---|
コミット メッセージ | JRA-123 JRA-234 JRA-345 #resolve 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
構文 | <ISSUE_KEY1> <ISSUE_KEY2> ... <ISSUE_KEYn> #<COMMAND_1> <optional COMMAND_1_ARGUMENTS> #<COMMAND_2> <optional COMMAND_2_ARGUMENTS> ... #<COMMAND_n> <optional COMMAND_n_ARGUMENTS> <ISSUE_KEY1> <ISSUE_KEY2> ... <ISSUE_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 JRA-123 JRA-234 JRA-345 #resolve #time 2d 5h #comment 期限前にタスクを完了 |
結果 | 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 Software のインスタンスでスマート コミットを使用できるようにするのは簡単です。
ツール | 接続の手順 |
---|---|
Bitbucket Cloud | まず、Jira Software と Bitbucket アカウントをリンクします。「Jira Cloud と Bitbucket Cloud の接続」を参照してください。 次に、Jira Software でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。 |
GitHub | まず、Jira Software と GitHub アカウントをリンクします。「Jira Cloud と GitHub の接続」を参照してください。 次に、Jira Software でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。 |
Fisheye | Jira Software と Fisheye 間のアプリケーション リンクを作成します。「別のアプリケーションにリンクする」を参照してください。 次に、Jira Software でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。 |
Crucible | Jira Software と Crucible 間のアプリケーション リンクを作成します。「別のアプリケーションにリンクする」を参照してください。 次に、Jira Software でスマート コミットを有効にします。「スマート コミットの有効化」を参照してください。 |
注意
Smart Commits only support the default Jira Software 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 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 Software user base. If the email address matches to multiple users in Jira Software, 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 Software sends an email notification to either the Jira Software user, or to the DVCS user (if a Jira Software user can't be identified). In rare cases, Jira Software doesn't have either of these email addresses, and the Smart Commit fails silently.
実行するスマート コミット コマンドは、特定の状況下では重複して表示されます。コミット履歴を変更すると、「新しい」コミットが作成され、「古い」コミットが置き換えられます。これらの「新しい」コミットに履歴書き換え前と同じスマート コミット コマンドが含まれる場合、同じスマート コミットが再び実行されるため、重複しているように見えます。git コマンドを変更するコミット履歴には、
git push --force
とgit merge --squash
が含まれます。以前の Bitbucket は、イベント配信中にマージ コミット フラグを Jira に送信していませんでした。そのため、「スマート コミット」では、すべてのコミットが通常のコミットとして扱されていました。今後は、CommitEvent が EventDelivery に対して COMMIT_MERGED フラグを含めて送信されるようになりました。したがって、次のような既定のマージ コミット形式を使用してください。
Merged in <branch name> (pull request #<PR id>)
<PR title>
Merged in <branch name> (pull request #<PR id>)
<PR title>
マージ後、マージ コミット メッセージに追加される PR タイトルには、スマート コミット コマンドを追加しないことをお勧めします。代わりに、マージ コミット メッセージを手動で編集して、スマート コミットが再び機能するようにしてください。
この内容はお役に立ちましたか?