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

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.
  • Tag-based triggering: An image pull is triggered based on the specified tags.

Examples

  • Expression-based triggering

    You can enter a simple regular expression, such as release-v. *. An image pull is triggered only after an image with a tag starting 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

    You can specify a maximum of 10 tags for which an image pull needs to be triggered. Then, an image pull is triggered only when images containing 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 repository information and image tag information. 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"
    }
}