でのコミットへの複数の作業アイテムの関連付け DevOps
1 つのコミットに対する複数の作業アイテムは、Azure DevOps、Bitbucket、GitHub、および GitLab の DevOps でサポートされています。
コミットメッセージの作業アイテム構文は、 システム定義>スクリプトインクルード モジュールの DevopsCommitMessageParserSNC スクリプトインクルードを使用して、組織内のプロセスを反映するようにカスタマイズできます。
コミットを作業アイテムにリンクするために、作業アイテムのネイティブ ID がコミットメッセージから抽出されます。ベースシステムでは、DevOps は次のコミットメッセージ形式をサポートしています。
/**
* Supported patterns
* Colon pattern
* Sample supported formats:
* 1. STRY1,STRY2: Additional bug fixes
* 2. STRY1 , STRY2 : Additional bug fixes
* 3. STRY1, STRY2 : Additional bug fixes
* Hash pattern
* Sample supported formats:
* 1. Fixes for #STRY1, #STRY2, #STRY3
* 2. Fixes @$#3 and #1 work item
* 3. Fixes for #STRY1 #STRY2 #STRY3
* 4. Fixes for AB#123
* Jira pattern
* Sample supported formats:
* 1. JRA-123 fixed
* 2. JRA-123 JRA-234 JRA-345 resolved
*/組織内のプロセスに合わせて追加のメッセージ形式のサポートを追加する場合は、[システム定義] > [スクリプトインクルード] モジュールに移動して、DevopsCommitMessageParser スクリプトインクルードにカスタムロジックを追加できます。DevopsCommitMessageParser スクリプトインクルードは DevopsCommitMessageParserSNC から拡張されます。DevopsCommitMessageParserSNC には、ベースシステムでサポートされているメッセージ形式の作業アイテムネイティブ ID を識別するために定義された 3 つの正規表現があります。角かっこで囲まれた作業項目のネイティブ ID を持つ新しいカスタム メッセージ形式を含めるには、次の例を参照してください。
var DevopsCommitMessageParser = Class.create();
DevopsCommitMessageParser.prototype = Object.extendsObject(DevopsCommitMessageParserSNC, {
initialize: function() {
DevopsCommitMessageParserSNC.prototype.initialize.call(this);
this._customPattern = /\[(.*?)\]/g; // The regex pattern to match the words written inside square brackets.
// Example commits message to match this custom pattern is : "[STRY1], [STRY2] Additional bug fixes"
},
getWorkitemsFromCommitMessage: function(message, branchName) {
var workitems = [];
// We first call the getWorkitemsFromCommitMessage method from the parent class to get the matching workitems ids for OOB formats
var defaultWI = DevopsCommitMessageParserSNC.prototype.getWorkitemsFromCommitMessage.call(this, message, branchName);
if (!gs.nil(defaultWI) && defaultWI.length > 0) {
workitems = workitems.concat(defaultWI);
}
// Now call your custom method that returns an array of workitem native IDs matching custom pattern
var customWI = this.getWIFromCustomPattern(message);
if (!gs.nil(customWI) && customWI.length > 0) {
workitems = workitems.concat(customWI);
}
// getUniqueWorkItems method from parent class removes duplicates from the workitems array
workitems = this.getUniqueWorkItems(workitems);
// return the final list
return workitems;
},
getWIFromCustomPattern: function(message) {
var wi = [];
var l;
var match;
var matches = message.match(this._customPattern);
if (gs.nil(matches))
return wi;
for (var i = 0; i < matches.length; i++) {
l = matches[i].length;
match = matches[i].substring(1, l - 1); // trim the brackets
wi.push(match);
}
return wi;
},
type: 'DevopsCommitMessageParser'
});Azure DevOps ユーザーインターフェイスを使用した作業アイテムのコミットへのリンクは、DevOps でもサポートされています。
関連付けられた作業アイテムのリストは、DevOps コミットレコードとパイプライン UI で表示できます。