Skip to content

Commit 60a7c7d

Browse files
[fix] the linting issues
1 parent 6bdeebb commit 60a7c7d

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

content/guides/azure-pipelines.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ params:
1212
1313
## Prerequisites
1414

15-
Before you begin, ensure the following requirements are met:
15+
Before you begin, ensure you have the following requirements:
1616

1717
- A [Docker Hub account](https://hub.docker.com) with a generated access token.
1818
- An active [Azure DevOps project](https://dev.azure.com/) with a connected [Git repository](https://learn.microsoft.com/en-us/azure/devops/repos/git/?view=azure-devops).
@@ -30,12 +30,13 @@ This guide walks you through building and pushing Docker images using [Azure Pip
3030
To securely authenticate with Docker Hub using Azure Pipelines:
3131

3232
1. Navigate to **Project Settings > Service Connections** in your Azure DevOps project.
33-
2. Click **New service connection > Docker Registry**.
33+
2. Select **New service connection > Docker Registry**.
3434
3. Choose **Docker Hub** and provide your Docker Hub credentials or access token.
3535
4. Give the service connection a recognizable name, such as `my-docker-registry`.
3636
5. Grant access only to the specific pipeline(s) that require it for improved security and least privilege.
3737

3838
> [!IMPORTANT]
39+
>
3940
> Avoid selecting the option to grant access to all pipelines unless absolutely necessary. Always apply the principle of least privilege.
4041
4142
## Step 2: Create your pipeline
@@ -120,9 +121,9 @@ This pipeline automates the Docker image build and deployment process for the ma
120121
- Logs out from Docker if running on a self-hosted Linux agent.
121122

122123

123-
## Detailed Step-by-Step Explanation
124+
## How the pipeline works
124125

125-
### Step 1: Define Pipeline Triggers
126+
### Step 1: Define pipeline triggers
126127

127128
```yaml
128129
trigger:
@@ -139,7 +140,7 @@ This pipeline is triggered automatically on:
139140
> [!TIP]
140141
> Learn more: [Define pipeline triggers in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops)
141142

142-
### Step 2: Define Common Variables
143+
### Step 2: Define common variables
143144

144145
```yaml
145146
variables:
@@ -155,30 +156,30 @@ These variables ensure consistent naming, versioning, and reuse throughout the p
155156
- `latestTag`: a stable alias for your most recent image
156157

157158
> [!IMPORTANT]
159+
>
158160
> The variable `dockerUsername` is not set automatically.
159161
> Set it securely in your Azure DevOps pipeline variables:
160-
> 1. Go to **Pipelines > Edit > Variables**
161-
> 2. Add `dockerUsername` with your Docker Hub username
162+
> 1. Go to **Pipelines > Edit > Variables**
163+
> 2. Add `dockerUsername` with your Docker Hub username
162164
>
163165
> Learn more: [Define and use variables in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch)
164166

165-
### Step 3: Define Pipeline Stages and Jobs
167+
### Step 3: Define pipeline stages and jobs
166168

167169
```yaml
168170
stages:
169171
- stage: BuildAndPush
170172
displayName: Build and Push Docker Image
171173
```
172174

173-
This stage executes only if:
174-
175-
- The source branch is main.
175+
This stage executes only if the source branch is `main`.
176176

177177
> [!TIP]
178+
>
178179
> Learn more: [Stage conditions in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml)
179180

180181

181-
### Step 4: Job Configuration
182+
### Step 4: Job configuration
182183

183184
```yaml
184185
jobs:
@@ -193,9 +194,10 @@ jobs:
193194
This job utilizes the latest Ubuntu VM image with Docker support, provided by Microsoft-hosted agents. It can be replaced with a custom pool for self-hosted agents if necessary.
194195

195196
> [!TIP]
197+
>
196198
> Learn more: [Specify a pool in your pipeline](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues?view=azure-devops&tabs=yaml%2Cbrowser)
197199

198-
#### Step 4.1 Checkout Code
200+
#### Step 4.1: Checkout code
199201

200202
```yaml
201203
steps:
@@ -206,9 +208,10 @@ steps:
206208
This step pulls your repository code into the build agent, so the pipeline can access the Dockerfile and application files.
207209

208210
> [!TIP]
211+
>
209212
> Learn more: [checkout step documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines)
210213

211-
#### Step 4.2 Authenticate to Docker Hub
214+
#### Step 4.2: Authenticate to Docker Hub
212215

213216
```yaml
214217
- task: Docker@2
@@ -218,12 +221,13 @@ This step pulls your repository code into the build agent, so the pipeline can a
218221
containerRegistry: 'my-docker-registry' # Replace with your service connection name
219222
```
220223

221-
Uses a preconfigured Azure DevOps Docker registry service connection to authenticate securely without exposing credentials directly.
224+
Uses a pre-configured Azure DevOps Docker registry service connection to authenticate securely without exposing credentials directly.
222225

223226
> [!TIP]
227+
>
224228
> Learn more: [Use service connections for Docker Hub](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops#docker-hub-or-others)
225229

226-
#### Step 4.3 Build the Docker Image
230+
#### Step 4.3: Build the Docker image
227231

228232
```yaml
229233
- task: Docker@2
@@ -252,11 +256,12 @@ This builds the image with:
252256
- Provenance attestation to verify how and where the image was built
253257

254258
> [!TIP]
259+
>
255260
> Learn more:
256261
> - [Docker task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/docker-v2?view=azure-pipelines&tabs=yaml)
257262
> - [Docker SBOM Attestations](/manuals/build/metadata/attestations/slsa-provenance.md)
258263

259-
#### Step 4.4 Push the Docker Image
264+
#### Step 4.4: Push the Docker image
260265

261266
```yaml
262267
- task: Docker@2
@@ -276,7 +281,7 @@ This uploads both tags to Docker Hub:
276281
- `$(buildTag)` ensures traceability per run.
277282
- `latest` is used for most recent image references.
278283

279-
#### Step 4.5 Logout from Docker (Self-Hosted Agents)
284+
#### Step 4.5 Logout of Docker (self-hosted agents)
280285

281286
```yaml
282287
- script: docker logout
@@ -289,15 +294,16 @@ Executes docker logout at the end of the pipeline on Linux-based self-hosted age
289294
## Summary
290295

291296
With this Azure Pipelines CI setup, you get:
297+
292298
- Secure Docker authentication using a built-in service connection.
293299
- Automated image building and tagging triggered by code changes.
294300
- Efficient builds leveraging Docker BuildKit cache.
295301
- Safe cleanup with logout on persistent agents.
296302
- Build images that meet modern software supply chain requirements with SBOM and attestation
297303

298-
## Further Reading
304+
## Learn more
299305

300-
- [Azure Pipelines Documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops) - Comprehensive guide to configuring and managing CI/CD pipelines in Azure DevOps.
301-
- [Docker Task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker) - Detailed reference for using the Docker task in Azure Pipelines to build and push images.
302-
- [Docker Buildx Bake](/manuals/build/bake/_index.md) - Explore Docker's advanced build tool for complex, multi-stage, and multi-platform build setups. See also the [Mastering Buildx Bake Guide](/guides/bake/index.md) for practical examples and best practices.
303-
- [Docker Build Cloud](/guides/docker-build-cloud/_index.md) - Learn about Docker's managed build service for faster, scalable, and multi-platform image builds in the cloud.
306+
- [Azure Pipelines Documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops): Comprehensive guide to configuring and managing CI/CD pipelines in Azure DevOps.
307+
- [Docker Task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker): Detailed reference for using the Docker task in Azure Pipelines to build and push images.
308+
- [Docker Buildx Bake](/manuals/build/bake/_index.md): Explore Docker's advanced build tool for complex, multi-stage, and multi-platform build setups. See also the [Mastering Buildx Bake Guide](/guides/bake/index.md) for practical examples and best practices.
309+
- [Docker Build Cloud](/guides/docker-build-cloud/_index.md): Learn about Docker's managed build service for faster, scalable, and multi-platform image builds in the cloud.

0 commit comments

Comments
 (0)