Skip to main content
Version: QB14

Webhooks

info

Since 8.0.12

Webhooks allow you to subscribe to build events on your QuickBuild instance. When one of those events is triggered, we'll send a HTTP POST payload to the webhook's configured URL.

You can set up Webhooks for one configuration as many as you want. The configuration setting looks like below:

Event

The build events include:

  • BUILD_STARED when build is stared
  • BUILD_FINISHED when build is finished
  • BUILD_RECOMMENDED when build is recommended
  • BUILD_UNRECOMMENDED when build is un-recommended

Payload

The payload data can be any JSON string. If it is empty, the build model will be delivered.

Below is an example of build model:

{
"configurationId": 123, // configuration id
"configurationPath": "root/PMEase/Quickbuild", // configuration path
"id": 345, // build id
"version": "1.3.4",
"status": "RUNNING", // build status, can be: SUCCESSFUL, RECOMMENDED, FAILED, CANCELLED, TIMEOUT, RUNNING
"requester": "admin",
"duration": 100, // in milliseconds
"beginDate": "20180728T03:51:58.573+0000", // in ISO8601 format, yyyyMMdd'T'HH:mm:ss.SSSZ
"endDate": "20180728T03:51:58.573+0000", // in ISO8601 format, yyyyMMdd'T'HH:mm:ss.SSSZ
}

Delivery headers

HTTP POST payloads that are delivered to your webhook's configured URL endpoint will contain several special headers:

HeaderDescription
X-QB-EventTypeName of the event type that triggered the delivery, can be: BUILD_STARTED, BUILD_FINISHED
X-QB-SignatuerThe HMAC hex digest of the response body. This header will be sent if the webhook is configured with a secret. The HMAC hex digest is generated using the sha1 hash function and the secret as the HMAC key.

HMAC signature

Below is an example with Java on how to create the signature:

public class HmacSha1Signature {
private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

private static String toHexString(byte[] bytes) {
try (Formatter formatter = new Formatter()) {
for (byte b : bytes) {
formatter.format("%02x", b);
}

return formatter.toString();
}
}

public static String calculateRFC2104HMAC(String data, String key)
throws SignatureException, NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
mac.init(signingKey);
return toHexString(mac.doFinal(data.getBytes()));
}

}