This topic describes how to build a DevOps environment based on containers in the Container Registry console.

Step 1: Create a repository

  1. If the account you used to log on to Container Registry has not activated Alibaba Cloud Code, click Bind Account next to Alibaba Cloud Code on the Code Source page to activate Alibaba Cloud Code.
    Note If your account has activated Alibaba Cloud Code, your projects on Alibaba Cloud Code are listed by default.
  2. You can create a repository based on the projects on Alibaba Cloud Code.
    Note We recommend that you select Automatically build image in the Build Settings section. After you modify the code on Alibaba Cloud Code, an automatic build of the repository is triggered and the new image is pushed to Container Registry.
  3. Set the master branch of your project as the image tag latest.
    Then, if you want to use this repository image, you can directly use**/dockertest, without specifying the tag as latest. The stable master branch is used by default to create the stable image tag latest.

Step 2: Build the repository

On the details page of the created repository, click Build to build the repository based on the two build rules added.

After you modify and commit the code in the test branch of your project on Alibaba Cloud Code, the repository is automatically built based on the second build rule to generate a new image tag.

Step 3: Bind a repository webhook

A repository webhook can subscribe to events upon the generation of new image tags. We recommend that you use to generate a request URL and then bind it to the repository webhook. After a new image is generated, you can view the webhook access record, including the request time, request parameters, and request result. The request parameters provide information about the current repository.

Step 4: Bind a webhook for Container Service

  1. Log on to Container Service console. In the left-side navigation pane, click Applications.
  2. Select the target cluster and click the name of the created application to enter the application details page.
  3. Click Create Trigger to create a redeployment webhook, and copy the webhook URL.
    Create a webhook
  4. Return to the image information page and click Add Rule. In the dialog box that appears, enter the webhook URL.
    Create a webhook

    After you modify the code on Alibaba Cloud Code, an image is automatically built, and Container Service is triggered to automatically redeploy the image for the relevant application.