Web triggers
Learn how web triggers connect Unity Version Control to external systems and how to write web trigger syntax.
読み終わるまでの所要時間 4 分最終更新 9時間前
You can use web triggers to connect your UVCS server with an external system. The UVCS server sends an HTTP request to a configured URL, using by default. The request body is a JSON dictionary that contains:
POST- The trigger variables.
- The key with a human-readable description of the operation.
content - The trigger's standard input data under the key. By default,
INPUTis a string that contains the input lines as a JSON-encoded array. If you use theINPUToption,--jsonis a JSON array.INPUT
You can use the endpoint that receives the JSON payload to create extensions to your UVCS server. For example, you can use a web trigger to ensure that any changesets created have a valid comment, or to send deployment requests.
Web trigger syntax
Set the trigger script to followed by the request options.
webtriggerwebtrigger [-X <method>] <url> [-H '<name>: <value>']... [--json] [--signing-secret '<secret>'] [--no-wait] [--var '<KEY>: <value>']...
The following table describes the options and arguments of the script.
webtriggerOption or argument | Required | Description |
|---|---|---|
| No | HTTP method of the request: |
| Yes | Absolute |
| No | Header to add to the request, as |
| No | Sends the |
| No | Signs the request body with HMAC-SHA256 and the specified secret. The signature goes in the |
| No | Sends the request in the background without waiting for the response. If the request times out, fails with a network error, or returns a 408, 429, or 5xx status code, the server retries it up to three times. The server logs failures, and they don't fail the operation. |
| No | Variable to replace in the request, as |
Options are case-sensitive. Separate options and values with spaces. If a value contains spaces or tabs, such as a header, enclose it in single or double quotes. Inside quotes, use a backslash to escape , , or . Other backslashes stay as they are.
\'"Without , if the endpoint returns an error status code, the trigger fails and shows the response content. A failed trigger stops the operation.
--no-waitbefore-*Every request includes the following headers:
- : Set to
Content-Type.application/json - : Set to
Accept.text/plain - : A unique ID for each request.
X-UVCS-DeliveryId
The request body is a JSON object with the trigger environment variables, a key with a human-readable description of the operation, and the key.
contentINPUTThe server stores the and values encrypted.
--signing-secret--varThe following command creates a web trigger that sends a signed request with a custom header to a URL that contains a variable, without waiting for the response.
PUTcm trigger create after-checkin NotifyCI "webtrigger -X PUT https://ci.example.com/hooks/@TOKEN -H 'X-Team: core' --signing-secret '<secret>' --no-wait --var 'TOKEN: <token>'"
Web trigger notifications
You can use web triggers to send notifications about operations in your UVCS server. For example, you can set up the following:
- A Slack integration to notify your team when there are new changesets in your main branch.
- A Discord integration to notify your team when someone creates a new branch.
- An SMS alert system for relevant operations.
Additional resources
- A comprehensive list of trigger operations that you can use with your web triggers.
- UVCS trigger reference.
- Create a Slack web trigger.
- Create a Discord web trigger.