Send build status notifications via Webhook
urls: Required, list of Webhook notification addresses, supports multiple addressesmethod: Optional, HTTP request method, supports GET, POST, PUT, etc. Default is POST.content_type: Optional, Content-Type of HTTP request. Default is application/json.headers: Optional, custom HTTP request headers, format is an array of key=value pairsvalid_response_codes: Optional, list of valid HTTP response status codes, only requests returning these status codes
are considered successful. Format is an array of integersdebug: Optional, whether to enable debug mode, true or false, default is false. When enabled, detailed request and
response information will be outputusername: Optional, username for HTTP basic authentication.password: Optional, password for HTTP basic authentication.token_type: Optional, type of authentication token, such as Bearer, Token, etc. Default is Bearer.
Added to the Authorization request header, format is Authorization: ${token_type} ${token_value}.token_value: Optional, value of the authentication token.signature_header: Optional, name of the signature request header, used for request HMAC-SHA256 signature verificationsignature_secret: Optional, signature key, used to generate request HMAC-SHA256 signaturesskip_verify: Optional, whether to skip SSL certificate verification. Default is false.template: Optional, custom message template, used to format the message content to be sent. If not set, the default
JSON format will be used.
The template variable replacement supports two replacement methods:
{{ variable }} syntax to reference environment variables. Variable values with special characters
will be escaped.${ variable },
This method may cause JSON parsing errors if environment variables contain characters like double quotes or line breaks
that could disrupt the JSON format.The variable can use environment variables provided by CNB, such as ${CNB_REPO_NAME}, {{ CNB_REPO_NAME }}.
{
"repoName": "{{ CNB_REPO_NAME }}",
"repoUrl": "${CNB_REPO_URL_HTTPS}"
}
If template is not set, the default JSON string format will be used as the request body. The default format is as
follows, variable meanings can be found here:
{
"CNB_WEB_PROTOCOL",
"CNB_WEB_HOST",
"CNB_WEB_ENDPOINT",
"CNB_API_ENDPOINT",
"CNB_GROUP_SLUG",
"CNB_GROUP_SLUG_LOWERCASE",
"CNB_EVENT",
"CNB_EVENT_URL",
"CNB_BRANCH",
"CNB_BRANCH_SHA",
"CNB_TOKEN_USER_NAME",
"CNB_TOKEN",
"CNB_TOKEN_FOR_AI",
"CNB_IS_CRONEVENT",
"CNB_DOCKER_REGISTRY",
"CNB_HELM_REGISTRY",
"CNB_BEFORE_SHA",
"CNB_COMMIT",
"CNB_COMMIT_SHORT",
"CNB_COMMIT_MESSAGE",
"CNB_COMMIT_MESSAGE_TITLE",
"CNB_COMMITTER",
"CNB_COMMITTER_EMAIL",
"CNB_IS_TAG",
"CNB_TAG_MESSAGE",
"CNB_TAG_RELEASE_TITLE",
"CNB_TAG_RELEASE_DESC",
"CNB_TAG_IS_RELEASE",
"CNB_TAG_IS_PRE_RELEASE",
"CNB_IS_NEW_BRANCH",
"CNB_IS_NEW_BRANCH_WITH_UPDATE",
"CNB_REPO_SLUG",
"CNB_REPO_SLUG_LOWERCASE",
"CNB_REPO_NAME",
"CNB_REPO_NAME_LOWERCASE",
"CNB_REPO_ID",
"CNB_REPO_URL_HTTPS",
"CNB_BUILD_ID",
"CNB_BUILD_WEB_URL",
"CNB_BUILD_START_TIME",
"CNB_BUILD_USER",
"CNB_BUILD_USER_ID",
"CNB_BUILD_STAGE_NAME",
"CNB_BUILD_JOB_NAME",
"CNB_BUILD_JOB_KEY",
"CNB_BUILD_WORKSPACE",
"CNB_BUILD_FAILED_MSG",
"CNB_BUILD_FAILED_STAGE_NAME",
"CNB_PIPELINE_NAME",
"CNB_PIPELINE_KEY",
"CNB_PIPELINE_ID",
"CNB_PIPELINE_DOCKER_IMAGE",
"CNB_RUNNER_IP",
"CNB_CPUS",
"CNB_IS_RETRY",
"CNB_PULL_REQUEST",
"CNB_PULL_REQUEST_LIKE",
"CNB_PULL_REQUEST_PROPOSER",
"CNB_PULL_REQUEST_TITLE",
"CNB_PULL_REQUEST_BRANCH",
"CNB_PULL_REQUEST_SHA",
"CNB_PULL_REQUEST_TARGET_SHA",
"CNB_PULL_REQUEST_MERGE_SHA",
"CNB_PULL_REQUEST_SLUG",
"CNB_PULL_REQUEST_ACTION",
"CNB_PULL_REQUEST_ID",
"CNB_PULL_REQUEST_IID",
"CNB_PULL_REQUEST_REVIEWERS",
"CNB_PULL_REQUEST_REVIEW_STATE",
"CNB_REVIEW_REVIEWED_BY",
"CNB_REVIEW_LAST_REVIEWED_BY",
"CNB_VSCODE_WEB_URL",
"CNB_ISSUE_ID",
"CNB_ISSUE_IID",
"CNB_ISSUE_TITLE",
"CNB_ISSUE_DESCRIPTION",
"CNB_ISSUE_OWNER",
"CNB_ISSUE_STATE",
"CNB_ISSUE_IS_RESOLVED",
"CNB_COMMENT_ID",
"CNB_COMMENT_BODY"
}
# .cnb.yml
main:
push:
- stages:
- name: notify
image: cnbcool/webhook
settings:
urls:
- https://api.example.com/webhook
method: POST
content_type: application/json
template: |
{
"owner": "{{ CNB_BUILD_USER }}",
"repo": "{{ CNB_REPO_SLUG }}",
"url": "{{ CNB_REPO_URL_HTTPS }}",
"event": "{{ CNB_EVENT }}"
}
# .cnb.yml
main:
push:
- stages:
- name: notify
image: cnbcool/webhook
settings:
urls:
- https://api.example.com/webhook1
- https://api.example.com/webhook2
method: POST
username: webhook-user
password: webhook-password
content_type: application/json
template: |
{
"owner": "{{ CNB_BUILD_USER }}",
"repo": "{{ CNB_REPO_SLUG }}",
"url": "{{ CNB_REPO_URL_HTTPS }}",
"event": "{{ CNB_EVENT }}"
}
headers:
- "X-Custom-Header=custom-value"
- "Authorization=Bearer my-token"
token_type: "Bearer"
token_value: "my-token"
signature_header: "X-CNB-Signature"
signature_secret: "your-signature-secret"
valid_response_codes: [200, 201, 204]
skip_verify: false
debug: true