|
Property
|
Description
|
|---|---|
|
mksis.si.webhook.enable
|
When set to true, webhook event triggers are enabled.
If set to false, all webhook configurations are ignored.
Default value of the property is true.
|
|
mksis.si.webhook.notifier.maxThreads
|
Sets the maximum number of threads that can be used to send webhook notifications concurrently.
Increasing this value can improve performance when sending many webhook notifications, but it may also increase resource usage on the server.
Default value of the property is 5.
|
|
mksis.si.webhook.notifier.retry.attemptDelay
|
Sets the delay for checking the retry queue for failed webhook deliveries that are ready to be retried and resubmitted.
A longer delay can help prevent overwhelming the webhook endpoint with retry attempts, but it may also increase the time required to successfully send the notification.
Default value of the property is 30 seconds.
|
|
mksis.si.webhook.notifier.retry.cleanupDelay
|
Sets the delay after which failed webhook notifications are removed from the retry queue.
This helps prevent the retry queue from growing indefinitely and consuming excessive resources.
Default value of the property is 300 seconds.
|
|
mksis.si.webhook.notifier.retry.maxThreads
|
Sets the maximum number of threads that can be used to retry sending failed webhook notifications concurrently.
Increasing this value can improve performance when retrying many failed webhook notifications, but it may also increase resource usage on the server.
Default value of the property is 2.
|
|
mksis.si.webhook.notifier.timeout
|
Sets the timeout for webhook notification delivery attempts.
If a webhook notification cannot be delivered within this time, it is considered a failure and is retried according to the retry policy.
Default value of the property is 2 seconds.
|
|
mksis.si.webhook.trigger.script
|
The script from the mksis.triggers.scripts directory that is executed when a webhook event is triggered. This script is responsible for sending the webhook payload to the specified webhook URL.
Ensure that the script exists in the mksis.triggers.scripts directory. If it is not set, webhook events are not sent.
|
# 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=
|
|
• The url, secret, and projectpath can be obtained from the PTC RV&S External SCM repository created in Codebeamer. For more information see, Creating Webhook Secrets in Codebeamer topic in Codebeamer 3.3 and later Help Centre.
• PTC recommends using Oauth token authentication for user validation.
• Ensure that clientsecret is obtained in encrypted format and must be decrypted within webhook.js to generate the authentication token. Example, if Base64 is used as the encryption method, webhook.js must be updated to apply the appropriate Base64 decoding routine to derive the token.
|
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
|
|
The Server.createChangePackage.pre event can be configured in the webhookevents.list file for validating the user and item during the creation of a change package. It does not send any webhook notification to Codebeamer. For more information, see the next section.
|
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");
}
}
|
|
This is a sample script that shows how the assigned user can be validated. You can modify the script based on your business requirements.
|