Container Registry provides a webhook for each repository to push notifications about successful image building. This facilitates the redeployment of images for applications. If you set a webhook for Container Service, the applications on Container Service can be triggered to automatically pull and redeploy the new images that are built. This topic describes how to use a webhook.

Security rules on webhook usage

  • HTTP: Port 80 is used by default.

    If you want to use other ports, append the port numbers to the end of the webhook URL. You can use only the following port numbers: 80, 21, 443, 70, 210, 280, 488, 591, 777, and from 1025 to 65535.

  • HTTPS: Port 443 is used by default.

    Only the default port 443 is supported. If you want to use another port number, use HTTP.

Triggering methods

Container Registry provides two triggering methods for a webhook: expression-based triggering and tag-based triggering. If no triggering condition is specified, an image pull is triggered each time a new image tag is generated or the image tag is updated.

  • Expression-based triggering: Tags are filtered based on a regular expression. An image pull is triggered only when a tag matches the regular expression.

    You can enter a simple regular expression, such as release-v.*. An image pull is triggered only after an image with a tag that starts with release-v is built. Otherwise, no image pull is triggered and the access status code in the access log is "untriggered."

    Click Access Log to view the access history of the webhook.

  • Tag-based triggering: An image pull is triggered based on the specified tags.

    You can specify a maximum of 10 tags based on which an image pull needs to be triggered. Then, an image pull is triggered only when images with the specified tags are built. Otherwise, no image pull is triggered and the access status code in the access log is "untriggered."

    Click Access Log to view the access history of the webhook.

Notification content

The notification content of a webhook includes the information about the repository and image tag, as shown in the following code. The repository information includes the namespace, name, and region of the repository.

POST /payload HTTP/1.1

Content-Type: application/json
Request URL: https://cs.console.aliyun.com/hook/trigger?triggerUrl=YzRmMWE5YzM2ZjMzYzQ0NmFiMGYzNWJlMmM2MjM2NzIyfGV4cHJlc3N8cmVkZXBsb3l8MThlMmllY2drdXYyZXw=&secret=365a4a664b45615438716a487a75695a7ac48329224b35b073c2197374e7d62a
Request method: POST

{
    "push_data": {
        "digest": "sha256:457f4aa83fc9a6663ab9d1b0a6e2dce25a12a943ed5bf2c1747c58d48bbb4917", 
        "pushed_at": "2016-11-29 12:25:46", 
        "tag": "latest"
    }, 
    "repository": {
        "date_created": "2016-10-28 21:31:42", 
        "name": "repoTest", 
        "namespace": "namespace", 
        "region": "cn-hangzhou", 
        "repo_authentication_type": "NO_CERTIFIED", 
        "repo_full_name": "namespace/repoTest", 
        "repo_origin_type": "NO_CERTIFIED", 
        "repo_type": "PUBLIC"
    }
}