Skip to content

Commit d723880

Browse files
authored
Merge pull request #75681 from dlepow/multitask
[ACR] Multi-step task tutorial
2 parents e1bc3e5 + 14f6945 commit d723880

File tree

6 files changed

+535
-61
lines changed

6 files changed

+535
-61
lines changed

articles/container-registry/TOC.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
items:
2424
- name: 1 - Build images in Azure
2525
href: container-registry-tutorial-quick-task.md
26-
- name: 2 - Automate image builds
26+
- name: 2a - Automatic build on code commit
2727
href: container-registry-tutorial-build-task.md
28+
- name: 2b - Multi-step task on code commit
29+
href: container-registry-tutorial-multistep-task.md
2830
- name: 3 - Base image update builds
2931
href: container-registry-tutorial-base-image-update.md
3032
- name: Geo-replicate a registry

articles/container-registry/container-registry-tutorial-build-task.md

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: dlepow
66

77
ms.service: container-registry
88
ms.topic: tutorial
9-
ms.date: 09/24/2018
9+
ms.date: 05/04/2019
1010
ms.author: danlep
1111
ms.custom: "seodec18, mvc"
1212
# Customer intent: As a developer or devops engineer, I want to trigger
@@ -15,9 +15,11 @@ ms.custom: "seodec18, mvc"
1515

1616
# Tutorial: Automate container image builds in the cloud when you commit source code
1717

18-
In addition to a [quick task](container-registry-tutorial-quick-task.md), ACR Tasks supports automated Docker container image builds with the *build task*. In this tutorial, you use the Azure CLI to create a task that automatically triggers image builds in the cloud when you commit source code to a Git repository.
18+
In addition to a [quick task](container-registry-tutorial-quick-task.md), ACR Tasks supports automated Docker container image builds in the cloud when you commit source code to a Git repository.
1919

20-
In this tutorial, part two in the series:
20+
In this tutorial, your ACR task builds and pushes a single container image specified in a Dockerfile when you commit source code to a Git repo. To create a [multi-step task](container-registry-tasks-multi-step.md) that uses a YAML file to define steps to build, push, and optionally test multiple containers on code commit, see [Tutorial: Run a multi-step container workflow in the cloud when you commit source code](container-registry-tutorial-multistep-task.md). For an overview of ACR Tasks, see [Automate OS and framework patching with ACR Tasks](container-registry-tasks-overview.md)
21+
22+
In this tutorial:
2123

2224
> [!div class="checklist"]
2325
> * Create a task
@@ -31,59 +33,21 @@ This tutorial assumes you've already completed the steps in the [previous tutori
3133

3234
If you'd like to use the Azure CLI locally, you must have Azure CLI version **2.0.46** or later installed and logged in with [az login][az-login]. Run `az --version` to find the version. If you need to install or upgrade the CLI, see [Install Azure CLI][azure-cli].
3335

34-
## Prerequisites
35-
36-
### Get sample code
37-
38-
This tutorial assumes you've already completed the steps in the [previous tutorial](container-registry-tutorial-quick-task.md), and have forked and cloned the sample repository. If you haven't already done so, complete the steps in the [Prerequisites](container-registry-tutorial-quick-task.md#prerequisites) section of the previous tutorial before proceeding.
39-
40-
### Container registry
41-
42-
You must have an Azure container registry in your Azure subscription to complete this tutorial. If you need a registry, see the [previous tutorial](container-registry-tutorial-quick-task.md), or [Quickstart: Create a container registry using the Azure CLI](container-registry-get-started-azure-cli.md).
43-
44-
## Overview of ACR Tasks
45-
46-
A task defines the properties of an automated build, including the location of the container image source code and the event that triggers the build. When an event defined in the task occurs, such as a commit to a Git repository, ACR Tasks initiates a container image build in the cloud. By default, it then pushes a successfully built image to the Azure container registry specified in the task.
47-
48-
ACR Tasks currently support the following triggers:
49-
50-
* Commit to a Git repository
51-
* Base image update
52-
53-
In this tutorial, your ACR task builds and pushes a single container image specified in a Dockerfile. ACR Tasks can also run [multi-step tasks](container-registry-tasks-multi-step.md), using a YAML file to define steps to build, push, and optionally test multiple containers.
36+
[!INCLUDE [container-registry-task-tutorial-prereq.md](../../includes/container-registry-task-tutorial-prereq.md)]
5437

55-
## Create a build task
56-
57-
In this section, you first create a GitHub personal access token (PAT) for use with ACR Tasks. Then, you create a task that triggers a build when code is committed to your fork of the repository.
58-
59-
### Create a GitHub personal access token
60-
61-
To trigger a build on a commit to a Git repository, ACR Tasks need a personal access token (PAT) to access the repository. Follow these steps to generate a PAT in GitHub:
62-
63-
1. Navigate to the PAT creation page on GitHub at https://github.com/settings/tokens/new
64-
1. Enter a short **description** for the token, for example, "ACR Tasks Demo"
65-
1. Under **repo**, enable **repo:status** and **public_repo**
66-
67-
![Screenshot of the Personal Access Token generation page in GitHub][build-task-01-new-token]
68-
69-
1. Select the **Generate token** button (you may be asked to confirm your password)
70-
1. Copy and save the generated token in a **secure location** (you use this token when you define a task in the following section)
71-
72-
![Screenshot of the generated Personal Access Token in GitHub][build-task-02-generated-token]
73-
74-
### Create the build task
38+
## Create the build task
7539

7640
Now that you've completed the steps required to enable ACR Tasks to read commit status and create webhooks in a repository, you can create a task that triggers a container image build on commits to the repo.
7741

78-
First, populate these shell environment variables with values appropriate for your environment. 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 they appear in the example commands.
42+
First, populate these shell environment variables with values appropriate for your environment. 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.
7943

8044
```azurecli-interactive
8145
ACR_NAME=<registry-name> # The name of your Azure container registry
8246
GIT_USER=<github-username> # Your GitHub user account name
8347
GIT_PAT=<personal-access-token> # The PAT you generated in the previous section
8448
```
8549

86-
Now, create the task by executing following [az acr task create][az-acr-task-create] command:
50+
Now, create the task by executing the following [az acr task create][az-acr-task-create] command:
8751

8852
```azurecli-interactive
8953
az acr task create \
@@ -104,14 +68,6 @@ This task specifies that any time code is committed to the *master* branch in th
10468
Output from a successful [az acr task create][az-acr-task-create] command is similar to the following:
10569

10670
```console
107-
$ az acr task create \
108-
> --registry $ACR_NAME \
109-
> --name taskhelloworld \
110-
> --image helloworld:{{.Run.ID}} \
111-
> --context https://github.com/$GIT_USER/acr-build-helloworld-node.git \
112-
> --branch master \
113-
> --file Dockerfile \
114-
> --git-access-token $GIT_PAT
11571
{
11672
"agentConfiguration": {
11773
"cpu": 2
@@ -324,12 +280,11 @@ In this tutorial, you learned how to use a task to automatically trigger contain
324280

325281
<!-- LINKS - Internal -->
326282
[azure-cli]: /cli/azure/install-azure-cli
327-
[az-acr-task]: /cli/azure/acr
328-
[az-acr-task-create]: /cli/azure/acr
329-
[az-acr-task-run]: /cli/azure/acr
330-
[az-acr-task-list-runs]: /cli/azure/acr
283+
[az-acr-task]: /cli/azure/acr/task
284+
[az-acr-task-create]: /cli/azure/acr/task#az-acr-task-create
285+
[az-acr-task-run]: /cli/azure/acr/task#az-acr-task-run
286+
[az-acr-task-list-runs]: /cli/azure/acr/task#az-acr-task-list-runs
331287
[az-login]: /cli/azure/reference-index#az-login
332288

333-
<!-- IMAGES -->
334-
[build-task-01-new-token]: ./media/container-registry-tutorial-build-tasks/build-task-01-new-token.png
335-
[build-task-02-generated-token]: ./media/container-registry-tutorial-build-tasks/build-task-02-generated-token.png
289+
290+

0 commit comments

Comments
 (0)