Azure Pipelines Container Agents for Azure Devops
Create self-hosted Azure Pipelines Container Agents for Azure Devops.
Pipeline | Build Status |
---|---|
PipelineAgents |
Overview
The following explains how to easily build, setup and run self-hosted docker container agents using Azure Pipelines in Azure DevOps (ADO). The pipeline does the following for you:
- Creates an Azure Container Registry (ACR).
- Builds Docker Container Image for self-hosted Azure Pipelines Agent within that ACR.
- Starts Docker Container as Azure Container Instances (ACI).
- Connects ACIs to your Azure DevOps Agent Pool (Self-Hosted).
Repository
Requirements
- Azure DevOps Project
- Azure DevOps preview feature multi-stage pipelines enabeld
- Azure Resource Manager Service Connection
Setup
Create an Azure DevOps Agent pool within your Azure DevOps organization.
Generate a Personal Access Token (PAT) for your Azure DevOps Organization. When generating the (PAT), assign the following scopes:
- Agent Pools - Read & Manage
- Deployment Groups - Read & Manage
Create a new repository and clone/fork this repo into it.
In Pipelines/Library add a variable group named vg.PipelineAgents, with the following variable to avoid exposing keys & secrets in code
1
agentPoolToken = <agentPoolToken> # personal acces token for agent pool
In parameters.yml adjust following variables
1 2 3 4 5 6
acrName = <acrName> # Azure Container Registry Name (needs to be unique) adoUrl = https://dev.azure.com/<organization> # Azure DevOps Organization URL agentPool = <agentPool> # agent-pool name location = <location> # where your resources will be created resourceGroupName = <resourceGroupName> # where your agents will be placed serviceConnection = <serviceConnection> # arm service connection name
Create a new pipeline using the pipeline.yaml and run it.
Helper Scripts
Instead using an Azure Pipeline you can also run also these tasks locally using your local machine as agent. For that you can find a Helper file here.
If you’re not familiar with Docker at all I recommend the Docker Quickstart.
Docker Container image contents
The docker container images are based on the official Azure Pipelines VM images for Microsoft-hosted CI/CD.
Ubuntu / Debian
- Azure CLI (latest)
- Git (latest)
- PowerShell Core (latest)
- .NET SDK (2.1)
- Docker (18.06).3-ce
- Kubectl (1.14.4)
- Terraform (0.12.6)
Windows Server Core (ltsc2019)
- Chocolatey (latest)
- Azure CLI (latest)
- Git (latest)
- PowerShell Core (latest)
- Docker (in porgress)
- Kubectl (in porgress)
- Terraform (in porgress)
- Azure DevOps Project
- Azure DevOps preview feature multi-stage pipelines enabeld
- Azure Resource Manager Service Connection
- Azure DevOps Agent pool
- Personal Access Token (PAT)
- Variable Group
- Docker Quickstart
- Azure Pipelines VM images for Microsoft-hosted CI/CD
- GitHub Actions Virtual Environments