|
プロパティ
|
説明
|
|---|---|
|
mksis.si.webhook.enable
|
値を「true」に設定すると、Webhook イベントトリガーが有効になります。
値を「false」に設定すると、すべての Webhook 構成情報が無視されます。
このプロパティのデフォルト値は true です。
|
|
mksis.si.webhook.notifier.maxThreads
|
複数の Webhook 通知を同時に送信するためのスレッドの最大数を設定します。
この値を大きくすると、多数の Webhook 通知を送信する際のパフォーマンスが向上しますが、サーバー上のリソースの使用量が増加する可能性もあります。
このプロパティのデフォルト値は「5」です。
|
|
mksis.si.webhook.notifier.retry.attemptDelay
|
失敗した Webhook 配信のうち、再試行の準備が整った配信がないかどうかを再試行キューで確認して再サブミットするまでの遅延時間を設定します。
長い遅延時間を設定すると、再試行処理によって Webhook エンドポイントが過負荷状態になることを回避できますが、通知の送信にかかる時間が長くなる可能性もあります。
このプロパティのデフォルト値は 30 秒です。
|
|
mksis.si.webhook.notifier.retry.cleanupDelay
|
失敗した Webhook 通知を再試行キューから削除するまでの遅延時間を設定します。
これにより、再試行キューが無制限に拡大して多くのリソースを使用するのを防ぐことができます。
このプロパティのデフォルト値は 300 秒です。
|
|
mksis.si.webhook.notifier.retry.maxThreads
|
失敗した複数の Webhook 通知の送信を同時に再試行するためのスレッドの最大数を設定します。
この値を大きくすると、失敗した多数の Webhook 通知の送信を再試行する際のパフォーマンスが向上しますが、サーバー上のリソースの使用量が増加する可能性もあります。
このプロパティのデフォルト値は「2」です。
|
|
mksis.si.webhook.notifier.timeout
|
Webhook 通知配信試行のタイムアウトを設定します。
この時間内に Webhook 通知を配信できなかった場合、その通知は失敗したとみなされ、再試行ポリシーに従って配信が再試行されます。
このプロパティのデフォルト値は 2 秒です。
|
|
mksis.si.webhook.trigger.script
|
mksis.triggers.scripts ディレクトリ内のスクリプトのうち、Webhook イベントのトリガー時に実行されるスクリプト。このスクリプトにより、指定した Webhook URL に Webhook ペイロードが送信されます。
このスクリプトが mksis.triggers.scripts ディレクトリ内に存在することを確認してください。このスクリプトが設定されていない場合、Webhook イベントは送信されません。
|
# Webhook URL Configuration
webhooks.list=wb_project1,wb_project2
wb_project1.url=https://<codebeamer server>/<webhook URI for SCM Repository>
wb_project1.secret=<secret>
wb_project1.projectPath=/test1/project1.pj
wb_project2.url=https:////<codebeamer server>/<webhook URI for SCM Repository>
wb_project2.secret=<secret>
wb_project2.projectPath=/test1/project2.pj
#Configure the Codebeamer API endpoint that would be invoked to get json response containing tracker item details
webhook.itemvalidation.url=<protocol>://<hostname>:<port>/api/v3/items
#configure the timeout for item validation endpoint in ms. Default is 25 seconds.
webhook.itemvalidation.timeout=0
#configure the auth scheme for item validation.
webhook.itemvalidation.authscheme=oauth
#Configure OAuth details for a user, such as a service principal, that has access to the Codebeamer API and to Codebeamer projects that have RV&S SCM repositories created.
webhook.itemvalidation.oauth.clientid=
#Ensure to use an appropriate encryption technique to Encrypt clientsecret
webhook.itemvalidation.oauth.clientsecret=
webhook.itemvalidation.oauth.scope=
webhook.itemvalidation.oauth.tokenurl=
|
|
• url、secret、および projectpath は、Codebeamer で作成された PTC RV&S 外部 SCM リポジトリから取得できます。詳細については、Codebeamer 3.3 以降のヘルプセンターで、「Codebeamer での Webhook 秘密キーの作成」のトピックを参照してください。
• ユーザー検証には Oauth トークン認証を使用することをお勧めします。
• clientsecret が暗号化された形式で取得されていることを確認し、認証トークンを生成するために webhook.js 内で暗号化解除する必要があります。たとえば、暗号化方法として Base64 を使用する場合、適切な Base64 デコードルーチンを適用してトークンを取得できるように webhook.js を更新する必要があります。
|
Server.submitChangePackage.post
Server.rejectChangePackage.post
Server.closeChangePackage.post
Server.commitChangePackage.post
Server.discardChangePackageEntry.post
Server.reopenChangePackage.post
Project.newVariant.post
Project.deleteVariant.post
Project.deactivateVariant.post
Project.activateVariant.post
Project.checkpoint.post
|
|
変更パッケージの作成時にユーザーとアイテムを検証するために、webhookevents.list ファイルで Server.createChangePackage.pre イベントを構成できます。Codebeamer に Webhook 通知は送信されません。詳細については、次のセクションを参照してください。
|
function print(s){
webhookBean.logDebugMessage(s);
}
// Aborts script execution
{
environment.abortScript(msg,true);
}
#The function validateJsonResponse processes the JSON response from Codebeamer API endpoint and use it for validations.
#The below example demonstrates retrieving “assignedTo” field from response and comparing it with change package creator user from webhookBean”
#Update the function to add additional rules such as checking the “State” or other fields based on business requirements
function validateJsonResponse(jsonResponseObj) {
var JSONObject = Packages.org.json.JSONObject;
var body = jsonResponseObj;
// Parse JSON
var root = new JSONObject(body);
print("Payload root keys: " + root.keySet());
var assignedTo;
if (root.has("assignedTo")) {
assignedTo = root.getJSONArray("assignedTo");
} else {
abortScript("No user(s) assigned.");
}
if(!assignedTo || assignedTo == null){
abortScript("No user(s) assigned.");
}
var currentUser = webhookBean.getUserName();
var isAssigned = false;
for (var i = 0; i < assignedTo.length(); i++) {
var name = assignedTo.getJSONObject(i).getString("name");
if (name.equalsIgnoreCase(currentUser)) {
isAssigned = true;
break;
}
}
if(!isAssigned){
abortScript("Change Package creator and assigned user not matched.");
} else {
print("Assigned user validated successfully");
}
}
// OAuth token generation
function getOAuthAccessToken() {
try {
// Get OAuth configuration from webhook-config.properties
//Define a property and provide the client id for token generation.
var oauthClientId = webhookBean.getOauthClientId();
//Define a property and provide the client secret for token generation.
var oauthClientSecret = webhookBean.getOauthClientSecret();
//Define a property and provide the scope for token generation.
var oauthScope = webhookBean.getOauthScope();
//Define a property and provide the token URL for token generation.
var oauthTokenUrl = webhookBean.getOauthClientTokenUrl();
if (oauthClientId == null || oauthClientSecret == null || oauthScope == null || oauthTokenUrl == null) {
abortScript("OAuth configuration not found. Please set OAuthClientId, OAuthClientSecret, OAuthScope, and OAuthTokenUrl in webhook-config.properties");
}
//Ensure to use an appropriate decryption technique to retrieve oauthClientSecret received from getOauthClientSecret()
oauthClientSecret = new java.lang.String(java.util.Base64.getDecoder().decode(oauthClientSecret));
//Generate OAuth access token
var oauthAccessToken = environment.getAccessToken(oauthClientId, oauthClientSecret, oauthScope, oauthTokenUrl);
if (oauthAccessToken == null || oauthAccessToken.length() == 0) {
abortScript("Failed to generate OAuth access token");
}
print("getOAuthAccessToken : Token generated Successfully");
return "Bearer " + oauthAccessToken;
} catch (e) {
abortScript("Error generating OAuth token");
}
}
|
|
これは、担当ユーザーの検証方法を示すサンプルスクリプトです。このスクリプトは、ビジネス要件に合わせて変更することができます。
|