ドキュメント

Unity Version Control

Web triggers

Learn how web triggers connect Unity Version Control to external systems and how to write web trigger syntax.
読み終わるまでの所要時間 4 分最終更新 6時間前

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
POST
by default. The request body is a JSON dictionary that contains:
  • The trigger variables.
  • The
    content
    key with a human-readable description of the operation.
  • The trigger's standard input data under the
    INPUT
    key. By default,
    INPUT
    is a string that contains the input lines as a JSON-encoded array. If you use the
    --json
    option,
    INPUT
    is a JSON array.
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.
注
You can build your own web server to process web trigger requests made from the UVCS server, which allows you to create complex triggers. Otherwise, you can use a software integration service such as zapier.com, which integrate with a variety of popular applications.

Web trigger syntax

Set the trigger script to
webtrigger
followed by the request options.
webtrigger [-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
webtrigger
script.

Option or argument

Required

Description

-X
NoHTTP method of the request:
GET
,
POST
,
PUT
,
DELETE
,
PATCH
, or
HEAD
. The default is
POST
.
GET
and
HEAD
requests don't send a body.
url
YesAbsolute
http
or
https
URL that receives the request. Use only one URL. To use basic authentication, add the credentials to the URL as
user:password@
.
-H
NoHeader to add to the request, as
'<name>: <value>'
. Repeat the option to add more headers.
--json
NoSends the
INPUT
key as JSON instead of a string.
--signing-secret
NoSigns the request body with HMAC-SHA256 and the specified secret. The signature goes in the
X-UVCS-Signature
header as a lowercase hexadecimal string.
--no-wait
NoSends 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.
--var
NoVariable to replace in the request, as
'<KEY>: <value>'
. The server replaces
@KEY
in the URL, the header values, and the signing secret. Repeat the option to add more variables.
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
--no-wait
, if the endpoint returns an error status code, the trigger fails and shows the response content. A failed
before-*
trigger stops the operation.
Every request includes the following headers:
  • Content-Type
    : Set to
    application/json
    .
  • Accept
    : Set to
    text/plain
    .
  • X-UVCS-DeliveryId
    : A unique ID for each request.
The request body is a JSON object with the trigger environment variables, a
content
key with a human-readable description of the operation, and the
INPUT
key.
The server stores the
--signing-secret
and
--var
values encrypted.
The following command creates a web trigger that sends a signed
PUT
request with a custom header to a URL that contains a variable, without waiting for the response.
cm 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