教程:提交源代码时在云中运行多步骤容器工作流Tutorial: Run a multi-step container workflow in the cloud when you commit source code

快速任务以外,ACR 任务还支持在向 Git 存储库提交源代码时可自动触发的多步骤多容器式工作流。In addition to a quick task, ACR Tasks supports multi-step, multi-container-based workflows that can automatically trigger when you commit source code to a Git repository.

本教程介绍如何使用示例 YAML 文件来定义多步骤任务,以便在提交源代码时生成、运行一个或多个容器映像并将其推送到注册表。In this tutorial, you learn how to use example YAML files to define multi-step tasks that build, run, and push one or more container images to a registry when you commit source code. 若要创建仅在提交代码时自动生成单个映像的任务,请参阅教程:提交源代码时在云中自动化容器映像生成To create a task that only automates a single image build on code commit, see Tutorial: Automate container image builds in the cloud when you commit source code. 有关 ACR 任务的概述,请参阅使用 ACR 任务自动执行 OS 和框架修补For an overview of ACR Tasks, see Automate OS and framework patching with ACR Tasks,

本教程的内容:In this tutorial:

  • 使用 YAML 文件定义多步骤任务Define a multi-step task using a YAML file
  • 创建任务Create a task
  • (可选)将凭据添加到该任务,以便能够访问注册表Optionally add credentials to the task to enable access to another registry
  • 测试任务Test the task
  • 查看任务状态View task status
  • 使用代码提交触发任务Trigger the task with a code commit

本教程假设你已完成前面教程中的任务。This tutorial assumes you've already completed the steps in the previous tutorial. 如果尚未完成,请先完成前面教程先决条件部分中的步骤,再继续操作。If you haven't already done so, complete the steps in the Prerequisites section of the previous tutorial before proceeding.

备注

在 Azure China 中使用 Azure CLI 2.0 之前,请首先运行 az cloud set -n AzureChinaCloud 更改云环境。Before you can use Azure CLI 2.0 in Azure China, please run az cloud set -n AzureChinaCloud first to change the cloud environment. 如果要切换回全局 Azure,请再次运行 az cloud set -n AzureCloudIf you want to switch back to Global Azure, run az cloud set -n AzureCloud again.

若要在本地使用 Azure CLI,必须安装 Azure CLI 2.0.62 或更高版本,并使用 az login 登录。If you'd like to use the Azure CLI locally, you must have Azure CLI version 2.0.62 or later installed and logged in with az login. 运行 az --version 即可查找版本。Run az --version to find the version. 如果需要安装或升级 CLI,请参阅安装 Azure CLIIf you need to install or upgrade the CLI, see Install Azure CLI.

先决条件Prerequisites

获取示例代码Get sample code

本教程假定你已对示例存储库创建分支和克隆。This tutorial assumes you have forked and cloned the sample repository.

容器注册表Container registry

Azure 订阅中必须具有 Azure 容器注册表才能完成此教程。You must have an Azure container registry in your Azure subscription to complete this tutorial. 如果需要注册表,请参阅快速入门:使用 Azure CLI 创建容器注册表If you need a registry, see the Quickstart: Create a container registry using the Azure CLI.

创建 GitHub 个人访问令牌Create a GitHub personal access token

若要在向 Git 存储库提交内容时触发任务,ACR 任务需要用于访问存储库的个人访问令牌 (PAT)。To trigger a task on a commit to a Git repository, ACR Tasks need a personal access token (PAT) to access the repository. 如果还没有 PAT,请按照以下步骤在 GitHub 中生成一个:If you do not already have a PAT, follow these steps to generate one in GitHub:

  1. 导航到 GitHub 上的 PAT 创建页面 https://github.com/settings/tokens/newNavigate to the PAT creation page on GitHub at https://github.com/settings/tokens/new

  2. 输入令牌的简短说明,例如“ACR 任务演示”Enter a short description for the token, for example, "ACR Tasks Demo"

  3. 选择 ACR 的作用域以访问存储库。Select scopes for ACR to access the repo. 要像本教程一样访问公共存储库,请在“存储库”下方,启用“存储库:状态”和“public_repo” To access a public repo as in this tutorial, under repo, enable repo:status and public_repo

    GitHub 中个人访问令牌生成页面的屏幕截图

    备注

    若要生成 PAT 以访问专用 存储库,请选择完全存储库控制的作用域。To generate a PAT to access a private repo, select the scope for full repo control.

  4. 选择“生成令牌”按钮(可能会要求你确认密码) Select the Generate token button (you may be asked to confirm your password)

  5. 将生成的令牌复制并保存到安全位置(在后续部分定义任务时会使用此令牌)Copy and save the generated token in a secure location (you use this token when you define a task in the following section)

    GitHub 中已生成的个人访问令牌的屏幕截图

创建多步骤任务Create a multi-step task

完成启用 ACR 任务以读取提交状态及在存储库中创建 Webhook 所需的步骤后,请创建一个用于触发容器映像生成、运行和推送的多步骤任务。Now that you've completed the steps required to enable ACR Tasks to read commit status and create webhooks in a repository, create a multi-step task that triggers building, running, and pushing a container image.

YAML 文件YAML file

YAML 文件中定义多步骤任务的步骤。You define the steps for a multi-step task in a YAML file. 本教程的第一个示例多步骤任务在 taskmulti.yaml 文件中定义,该文件位于克隆的 GitHub 存储库的根目录:The first example multi-step task for this tutorial is defined in the file taskmulti.yaml, which is in the root of the GitHub repo that you cloned:

version: v1.0.0
steps:
# Build target image
- build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} -f Dockerfile .
# Run image 
- cmd: -t {{.Run.Registry}}/hello-world:{{.Run.ID}}
  id: test
  detach: true
  ports: ["8080:80"]
- cmd: docker stop test
# Push image
- push:
  - {{.Run.Registry}}/hello-world:{{.Run.ID}}

此多步骤任务执行以下操作:This multi-step task does the following:

  1. 运行 build 步骤,以基于工作目录中的 Dockerfile 生成映像。Runs a build step to build an image from the Dockerfile in the working directory. 该映像面向 Run.Registry(运行任务的注册表),并以唯一的 ACR 任务运行 ID 进行标记。The image targets the Run.Registry, the registry where the task is run, and is tagged with a unique ACR Tasks run ID.
  2. 运行 cmd 步骤,以在临时容器中运行该映像。Runs a cmd step to run the image in a temporary container. 此示例在后台启动一个长时间运行的容器,返回容器 ID,然后停止该容器。This example starts a long-running container in the background and returns the container ID, then stops the container. 在实际方案中,可以包含用于测试运行中容器的步骤,以确保该容器正常运行。In a real-world scenario, you might include steps to test the running container to ensure it runs correctly.
  3. push 步骤中,将生成的映像推送到运行注册表。In a push step, pushes the image that was built to the run registry.

任务命令Task command

首先,使用适用于环境的值填充这些 shell 环境变量。First, populate these shell environment variables with values appropriate for your environment. 此步骤并非必须执行的步骤,但它能让在此教程中执行多个 Azure CLI 命令更容易。This step isn't strictly required, but makes executing the multiline Azure CLI commands in this tutorial a bit easier. 如果未填充这些环境变量,则每当示例命令中出现每个值,都必须手动替换该值。If you don't populate these environment variables, you must manually replace each value wherever it appears in the example commands.

ACR_NAME=<registry-name>        # The name of your Azure container registry
GIT_USER=<github-username>      # Your GitHub user account name
GIT_PAT=<personal-access-token> # The PAT you generated in the previous section

现在,请执行以下 az acr task create 命令创建该任务:Now, create the task by executing the following az acr task create command:

az acr task create \
    --registry $ACR_NAME \
    --name example1 \
    --context https://github.com/$GIT_USER/acr-build-helloworld-node.git \
    --file taskmulti.yaml \
    --git-access-token $GIT_PAT

此任务指定,每当向 --context 指定的主分支存储库提交代码时,ACR 任务都要基于该分支中的代码运行该多步骤任务。 This task specifies that any time code is committed to the master branch in the repository specified by --context, ACR Tasks will run the multi-step task from the code in that branch. 存储库根目录中的 --file 指定的 YAML 文件将定义步骤。The YAML file specified by --file from the repository root defines the steps.

成功的 az acr task create 命令的输出应如下所示:Output from a successful az acr task create command is similar to the following:

{
  "agentConfiguration": {
    "cpu": 2
  },
  "creationDate": "2019-05-03T03:14:31.763887+00:00",
  "credentials": null,
  "id": "/subscriptions/<Subscription ID>/resourceGroups/myregistry/providers/Microsoft.ContainerRegistry/registries/myregistry/tasks/taskmulti",
  "location": "chinanorth",
  "name": "example1",
  "platform": {
    "architecture": "amd64",
    "os": "linux",
    "variant": null
  },
  "provisioningState": "Succeeded",
  "resourceGroup": "myresourcegroup",
  "status": "Enabled",
  "step": {
    "baseImageDependencies": null,
    "contextAccessToken": null,
    "contextPath": "https://github.com/gituser/acr-build-helloworld-node.git",
    "taskFilePath": "taskmulti.yaml",
    "type": "FileTask",
    "values": [],
    "valuesFilePath": null
  },
  "tags": null,
  "timeout": 3600,
  "trigger": {
    "baseImageTrigger": {
      "baseImageTriggerType": "Runtime",
      "name": "defaultBaseimageTriggerName",
      "status": "Enabled"
    },
    "sourceTriggers": [
      {
        "name": "defaultSourceTriggerName",
        "sourceRepository": {
          "branch": "master",
          "repositoryUrl": "https://github.com/gituser/acr-build-helloworld-node.git",
          "sourceControlAuthProperties": null,
          "sourceControlType": "Github"
        },
        "sourceTriggerEvents": [
          "commit"
        ],
        "status": "Enabled"
      }
    ]
  },
  "type": "Microsoft.ContainerRegistry/registries/tasks"
}

测试多步骤工作流Test the multi-step workflow

若要测试多步骤任务,请执行 az acr task run 命令手动将其触发:To test the multi-step task, trigger it manually by executing the az acr task run command:

az acr task run --registry $ACR_NAME --name example1

默认情况下,执行此命令时,az acr task run 命令会将日志流式传输到控制台。By default, the az acr task run command streams the log output to your console when you execute the command. 输出显示每个任务步骤的运行进度。The output shows the progress of running each of the task steps. 以下输出经过简化,只显示关键步骤。The output below is condensed to show key steps.

Queued a run with ID: cf19
Waiting for an agent...
2019/05/03 03:03:31 Downloading source code...
2019/05/03 03:03:33 Finished downloading source code
2019/05/03 03:03:33 Using acb_vol_cfe6bd55-3076-4215-8091-6a81aec3d1b1 as the home volume
2019/05/03 03:03:33 Creating Docker network: acb_default_network, driver: 'bridge'
2019/05/03 03:03:34 Successfully set up Docker network: acb_default_network
2019/05/03 03:03:34 Setting up Docker configuration...
2019/05/03 03:03:34 Successfully set up Docker configuration
2019/05/03 03:03:34 Logging in to registry: myregistry.azurecr.cn
2019/05/03 03:03:35 Successfully logged into myregistry.azurecr.cn
2019/05/03 03:03:35 Executing step ID: acb_step_0. Working directory: '', Network: 'acb_default_network'
2019/05/03 03:03:35 Scanning for dependencies...
2019/05/03 03:03:36 Successfully scanned dependencies
2019/05/03 03:03:36 Launching container with name: acb_step_0
Sending build context to Docker daemon  24.06kB

[...]

Successfully built f669bfd170af
Successfully tagged myregistry.azurecr.cn/hello-world:cf19
2019/05/03 03:03:43 Successfully executed container: acb_step_0
2019/05/03 03:03:43 Executing step ID: acb_step_1. Working directory: '', Network: 'acb_default_network'
2019/05/03 03:03:43 Launching container with name: acb_step_1
279b1cb6e092b64c8517c5506fcb45494cd5a0bd10a6beca3ba97f25c5d940cd
2019/05/03 03:03:44 Successfully executed container: acb_step_1
2019/05/03 03:03:44 Executing step ID: acb_step_2. Working directory: '', Network: 'acb_default_network'
2019/05/03 03:03:44 Pushing image: myregistry.azurecr.cn/hello-world:cf19, attempt 1

[...]

2019/05/03 03:03:46 Successfully pushed image: myregistry.azurecr.cn/hello-world:cf19
2019/05/03 03:03:46 Step ID: acb_step_0 marked as successful (elapsed time in seconds: 7.425169)
2019/05/03 03:03:46 Populating digests for step ID: acb_step_0...
2019/05/03 03:03:47 Successfully populated digests for step ID: acb_step_0
2019/05/03 03:03:47 Step ID: acb_step_1 marked as successful (elapsed time in seconds: 0.827129)
2019/05/03 03:03:47 Step ID: acb_step_2 marked as successful (elapsed time in seconds: 2.112113)
2019/05/03 03:03:47 The following dependencies were found:
2019/05/03 03:03:47
- image:
    registry: myregistry.azurecr.cn
    repository: hello-world
    tag: cf19
    digest: sha256:6b981a8ca8596e840228c974c929db05c0727d8630465de536be74104693467a
  runtime-dependency:
    registry: registry.hub.docker.com
    repository: library/node
    tag: 9-alpine
    digest: sha256:8dafc0968fb4d62834d9b826d85a8feecc69bd72cd51723c62c7db67c6dec6fa
  git:
    git-head-revision: 1a3065388a0238e52865db1c8f3e97492a43444c

Run ID: cf19 was successful after 18s

使用命令触发生成Trigger a build with a commit

通过手动运行任务对其进行测试后,可通过更改源代码手动触发该任务。Now that you've tested the task by manually running it, trigger it automatically with a source code change.

首先,确保你位于包含存储库的本地克隆的目录中:First, ensure you're in the directory containing your local clone of the repository:

cd acr-build-helloworld-node

接下来执行以下命令,创建新文件,并将其提交和推送给你在 GitHub 上的存储库分支:Next, execute the following commands to create, commit, and push a new file to your fork of the repo on GitHub:

echo "Hello World!" > hello.txt
git add hello.txt
git commit -m "Testing ACR Tasks"
git push origin master

执行 git push 命令时可能需要提供 GitHub 凭据。You may be asked to provide your GitHub credentials when you execute the git push command. 提供 GitHub 用户名并输入之前为密码创建的个人访问令牌 (PAT)。Provide your GitHub username, and enter the personal access token (PAT) that you created earlier for the password.

Username for 'https://github.com': <github-username>
Password for 'https://githubuser@github.com': <personal-access-token>

将提交内容推送到存储库后,ACR 任务创建的 Webhook 将在 Azure 容器注册表中触发并启动该任务。Once you've pushed a commit to your repository, the webhook created by ACR Tasks fires and kicks off the task in Azure Container Registry. 显示当前正在运行的任务的日志,以验证和监视生成进度:Display the logs for the currently running task to verify and monitor the build progress:

az acr task logs --registry $ACR_NAME

输出结果类似于以下内容,显示当前执行(或最近执行)的任务:Output is similar to the following, showing the currently executing (or last-executed) task:

Showing logs of the last created run.
Run ID: cf1d

[...]

Run ID: cf1d was successful after 37s

生成列表List builds

若要查看 ACR 任务对注册表完成的任务运行列表,请运行 az acr task list-runs 命令:To see a list of the task runs that ACR Tasks has completed for your registry, run the az acr task list-runs command:

az acr task list-runs --registry $ACR_NAME --output table

该命令产生的输出应如下所示。Output from the command should appear similar to the following. 将显示 ACR 任务已执行的运行,并在最近执行的任务的 TRIGGER 列中显示“Git Commit”:The runs that ACR Tasks has executed are displayed, and "Git Commit" appears in the TRIGGER column for the most recent task:

RUN ID    TASK       PLATFORM    STATUS     TRIGGER    STARTED               DURATION
--------  ---------  ----------  ---------  ---------  --------------------  ----------
cf1d      example1   linux       Succeeded  Commit     2019-05-03T04:16:44Z  00:00:37
cf1c      example1   linux       Succeeded  Commit     2019-05-03T04:16:44Z  00:00:39
cf1b      example1   linux       Succeeded  Manual     2019-05-03T03:10:30Z  00:00:31
cf1a      example1   linux       Succeeded  Commit     2019-05-03T03:09:32Z  00:00:31
cf19      example1   linux       Succeeded  Manual     2019-05-03T03:03:30Z  00:00:21

创建多注册表多步骤任务Create a multi-registry multi-step task

默认情况下,ACR 任务有权从运行任务的注册表推送或提取映像。ACR Tasks by default has permissions to push or pull images from the registry where the task runs. 你可能想要运行一个除了面向运行注册表以外,还面向其他一个或多个注册表的多步骤任务。You might want to run a multi-step task that targets one or more registries in addition to the run registry. 例如,你可能需要在一个注册表中生成映像,并在由生产系统访问的另一个注册表中存储具有不同标记的映像。For example, you might need to build images in one registry, and store images with different tags in a second registry that is accessed by a production system. 此示例演示如何创建此类任务,并提供另一个注册表的凭据。This example shows you how to create such a task and provide credentials for another registry.

如果没有另一个注册表,请为此示例创建一个注册表。If you don't already have a second registry, create one for this example. 如果需要注册表,请参阅上一教程快速入门:使用 Azure CLI 创建容器注册表If you need a registry, see the previous tutorial, or Quickstart: Create a container registry using the Azure CLI.

若要创建任务,需要注册表登录服务器的名称,其格式为“mycontainerregistrydate.azurecr.cn” (全小写)。To create the task, you need the name of the registry login server, which is of the form mycontainerregistrydate.azurecr.cn (all lowercase). 此示例使用第二个注册表来存储按生成日期标记的映像。In this example, you use the second registry to store images tagged by build date.

YAML 文件YAML file

本教程的第二个示例多步骤任务在 taskmulti-multiregistry.yaml 文件中定义,该文件位于克隆的 GitHub 存储库的根目录:The second example multi-step task for this tutorial is defined in the file taskmulti-multiregistry.yaml, which is in the root of the GitHub repo that you cloned:

version: v1.0.0
steps:
# Build target images
- build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} -f Dockerfile .
- build: -t {{.Values.regDate}}/hello-world:{{.Run.Date}} -f Dockerfile .
# Run image 
- cmd: -t {{.Run.Registry}}/hello-world:{{.Run.ID}}
  id: test
  detach: true
  ports: ["8080:80"]
- cmd: docker stop test
# Push images
- push:
  - {{.Run.Registry}}/hello-world:{{.Run.ID}}
  - {{.Values.regDate}}/hello-world:{{.Run.Date}}

此多步骤任务执行以下操作:This multi-step task does the following:

  1. 运行两个 build 步骤,以基于工作目录中的 Dockerfile 生成映像:Runs two build steps to build images from the Dockerfile in the working directory:
    • 第一个映像面向 Run.Registry(运行任务的注册表),并以 ACR 任务运行 ID 进行标记。The first targets the Run.Registry, the registry where the task is run, and is tagged with the ACR Tasks run ID.
    • 第二个映像面向创建任务时设置的(或通过传递给 az acr task create 的外部 values.yaml 文件提供的)regDate 值标识的注册表。The second targets the registry identified by the value of regDate, which you set when you create the task (or provide through an external values.yaml file passed to az acr task create). 此映像以运行日期进行标记。This image is tagged with the run date.
  2. 运行 cmd 步骤,以运行某个生成的容器。Runs a cmd step to run one of the built containers. 此示例在后台启动一个长时间运行的容器,返回容器 ID,然后停止该容器。This example starts a long-running container in the background and returns the container ID, then stops the container. 在实际方案中,可以测试正在运行的容器,以确保该容器正常运行。In a real-world scenario, you might test a running container to ensure it runs correctly.
  3. push 步骤中,将生成的第一个映像推送到运行注册表,将生成的第二个映像推送到 regDate 标识的注册表。In a push step, pushes the images that were built, the first to the run registry, the second to the registry identified by regDate.

任务命令Task command

使用前面定义的 shell 环境变量,通过执行以下 az acr task create 命令创建任务。Using the shell environment variables defined previously, create the task by executing the following az acr task create command. 请将 mycontainerregistrydate 替换为你的注册表名称。Substitute the name of your registry for mycontainerregistrydate.

az acr task create \
    --registry $ACR_NAME \
    --name example2 \
    --context https://github.com/$GIT_USER/acr-build-helloworld-node.git \
    --file taskmulti-multiregistry.yaml \
    --git-access-token $GIT_PAT \
    --set regDate=mycontainerregistrydate.azurecr.cn

添加任务凭据Add task credential

若要将映像推送到 regDate 值标识的注册表,请使用 az acr task credential add 命令将该注册表的登录凭据添加到任务。To push images to the registry identified by the value of regDate, use the az acr task credential add command to add login credentials for that registry to the task.

对于此示例,我们建议创建一个有权访问该注册表且范围为 AcrPush 角色的服务主体For this example, we recommend that you create a service principal with access to the registry scoped to the AcrPush role. 若要创建服务主体,请参阅此 Azure CLI 脚本To create the service principal, see this Azure CLI script.

在以下 az acr task credential add命令中传递服务主体应用程序 ID 和密码:Pass the service principal application ID and password in the following az acr task credential add command:

az acr task credential add --name example2 \
    --registry $ACR_NAME \
    --login-server mycontainerregistrydate.azurecr.cn \
    --username <service-principal-application-id> \
    --password <service-principal-password>

该 CLI 会返回添加的注册表登录服务器的名称。The CLI returns the name of the registry login server you added.

测试多步骤工作流Test the multi-step workflow

与前面的示例一样,若要测试多步骤任务,请执行 az acr task run 命令手动将其触发。As in the preceding example, to test the multi-step task, trigger it manually by executing the az acr task run command. 若要通过向 Git 存储库提交代码来触发任务,请参阅通过提交触发生成部分。To trigger the task with a commit to the Git repository, see the section Trigger a build with a commit.

az acr task run --registry $ACR_NAME --name example2

默认情况下,执行此命令时,az acr task run 命令会将日志流式传输到控制台。By default, the az acr task run command streams the log output to your console when you execute the command. 与前面一样,输出将显示每个任务步骤的运行进度。As before, the output shows the progress of running each of the task steps. 该输出已经过简化,只显示关键步骤。The output is condensed to show key steps.

输出:Output:

Queued a run with ID: cf1g
Waiting for an agent...
2019/05/03 04:33:39 Downloading source code...
2019/05/03 04:33:41 Finished downloading source code
2019/05/03 04:33:42 Using acb_vol_4569b017-29fe-42bd-83b2-25c45a8ac807 as the home volume
2019/05/03 04:33:42 Creating Docker network: acb_default_network, driver: 'bridge'
2019/05/03 04:33:43 Successfully set up Docker network: acb_default_network
2019/05/03 04:33:43 Setting up Docker configuration...
2019/05/03 04:33:44 Successfully set up Docker configuration
2019/05/03 04:33:44 Logging in to registry: mycontainerregistry.azurecr.cn
2019/05/03 04:33:45 Successfully logged into mycontainerregistry.azurecr.cn
2019/05/03 04:33:45 Logging in to registry: mycontainerregistrydate.azurecr.cn
2019/05/03 04:33:47 Successfully logged into mycontainerregistrydate.azurecr.cn
2019/05/03 04:33:47 Executing step ID: acb_step_0. Working directory: '', Network: 'acb_default_network'
2019/05/03 04:33:47 Scanning for dependencies...
2019/05/03 04:33:47 Successfully scanned dependencies
2019/05/03 04:33:47 Launching container with name: acb_step_0
Sending build context to Docker daemon  25.09kB

[...]

Successfully tagged mycontainerregistry.azurecr.cn/hello-world:cf1g
2019/05/03 04:33:55 Successfully executed container: acb_step_0
2019/05/03 04:33:55 Executing step ID: acb_step_1. Working directory: '', Network: 'acb_default_network'
2019/05/03 04:33:55 Scanning for dependencies...
2019/05/03 04:33:56 Successfully scanned dependencies
2019/05/03 04:33:56 Launching container with name: acb_step_1
Sending build context to Docker daemon  25.09kB

[...]

Successfully tagged mycontainerregistrydate.azurecr.cn/hello-world:20190503-043342z
2019/05/03 04:33:57 Successfully executed container: acb_step_1
2019/05/03 04:33:57 Executing step ID: acb_step_2. Working directory: '', Network: 'acb_default_network'
2019/05/03 04:33:57 Launching container with name: acb_step_2
721437ff674051b6be63cbcd2fa8eb085eacbf38d7d632f1a079320133182101
2019/05/03 04:33:58 Successfully executed container: acb_step_2
2019/05/03 04:33:58 Executing step ID: acb_step_3. Working directory: '', Network: 'acb_default_network'
2019/05/03 04:33:58 Launching container with name: acb_step_3
test
2019/05/03 04:34:09 Successfully executed container: acb_step_3
2019/05/03 04:34:09 Executing step ID: acb_step_4. Working directory: '', Network: 'acb_default_network'
2019/05/03 04:34:09 Pushing image: mycontainerregistry.azurecr.cn/hello-world:cf1g, attempt 1
The push refers to repository [mycontainerregistry.azurecr.cn/hello-world]

[...]

2019/05/03 04:34:12 Successfully pushed image: mycontainerregistry.azurecr.cn/hello-world:cf1g
2019/05/03 04:34:12 Pushing image: mycontainerregistrydate.azurecr.cn/hello-world:20190503-043342z, attempt 1
The push refers to repository [mycontainerregistrydate.azurecr.cn/hello-world]

[...]

2019/05/03 04:34:19 Successfully pushed image: mycontainerregistrydate.azurecr.cn/hello-world:20190503-043342z
2019/05/03 04:34:19 Step ID: acb_step_0 marked as successful (elapsed time in seconds: 8.125744)
2019/05/03 04:34:19 Populating digests for step ID: acb_step_0...
2019/05/03 04:34:21 Successfully populated digests for step ID: acb_step_0
2019/05/03 04:34:21 Step ID: acb_step_1 marked as successful (elapsed time in seconds: 2.009281)
2019/05/03 04:34:21 Populating digests for step ID: acb_step_1...
2019/05/03 04:34:23 Successfully populated digests for step ID: acb_step_1
2019/05/03 04:34:23 Step ID: acb_step_2 marked as successful (elapsed time in seconds: 0.795440)
2019/05/03 04:34:23 Step ID: acb_step_3 marked as successful (elapsed time in seconds: 11.446775)
2019/05/03 04:34:23 Step ID: acb_step_4 marked as successful (elapsed time in seconds: 9.734973)
2019/05/03 04:34:23 The following dependencies were found:
2019/05/03 04:34:23
- image:
    registry: mycontainerregistry.azurecr.cn
    repository: hello-world
    tag: cf1g
    digest: sha256:75354e9edb995e8661438bad9913deed87a185fddd0193811f916d684b71a5d2
  runtime-dependency:
    registry: registry.hub.docker.com
    repository: library/node
    tag: 9-alpine
    digest: sha256:8dafc0968fb4d62834d9b826d85a8feecc69bd72cd51723c62c7db67c6dec6fa
  git:
    git-head-revision: 9d9023473c46a5e2c315681b11eb4552ef0faccc
- image:
    registry: mycontainerregistrydate.azurecr.cn
    repository: hello-world
    tag: 20190503-043342z
    digest: sha256:75354e9edb995e8661438bad9913deed87a185fddd0193811f916d684b71a5d2
  runtime-dependency:
    registry: registry.hub.docker.com
    repository: library/node
    tag: 9-alpine
    digest: sha256:8dafc0968fb4d62834d9b826d85a8feecc69bd72cd51723c62c7db67c6dec6fa
  git:
    git-head-revision: 9d9023473c46a5e2c315681b11eb4552ef0faccc

Run ID: cf1g was successful after 46s

后续步骤Next steps

在本教程中,你已了解如何创建一个在向 Git 存储库提交源代码时可自动触发的多个步骤多容器式任务。In this tutorial, you learned how to create multi-step, multi-container-based tasks that automatically trigger when you commit source code to a Git repository. 有关多步骤任务的高级功能,包括并行和依赖性步骤执行,请参阅 ACR 任务 YAML 参考For advanced features of multi-step tasks, including parallel and dependent step execution, see the ACR Tasks YAML reference. 请转到下一教程来了解如何创建任务,用于在更新容器映像的基础映像时触发生成。Move on to the next tutorial to learn how to create tasks that trigger builds when a container image's base image is updated.