/azure-devops-agent

A self hosted agent for DevOps

Primary LanguageShellMIT LicenseMIT

azure-local-agent

A Dockerized solution for Azure DevOps self hosted agent.

Introduction

Welcome to Azure Local Agent repository.

The purpose of this repository is to provide a self hosted dockerized agent solution for our Azure DevOps pipelines to use for building and deploying our apps.

How to use this self hosted dockerized agent solution additional on pipelines defined in other project repositories:

  1. Open the Make file and go to the run: section.

... -e AZP_URL=https://dev.azure.com/cbsuk -e AZP_TOKEN=pusqt36t2saobskcdxrzxriw6kivqmup62fyuevteujmmqsolaeq -e AZP_AGENT_NAME=mydockeragent -e AZP_POOL=selfhosted dockeragent:latest --once

Adjust the bolded environment variables as needed, See below for details.

Definitions for variables

AZP_URL The URL of the Azure DevOps or Azure DevOps Server instance.

AZP_TOKEN Personal Access Token (PAT) with Agent Pools (read, manage) scope, created by a user who has permission to configure agents, at AZP_URL.

AZP_AGENT_NAME Agent name (default value: the container hostname).

AZP_POOL Agent pool name (default value: Default).

AZP_WORK Work directory (default value: _work).

Find more info here if you are curious:

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops

How to run the self hosted agent:

  1. Clone the repository
  2. Run the command make all

If the agent is not running this will be shown, so wait sometime for the dockerized agent to be up: image

As you can see, the agent is now starting: image 3. When the agent starts you'll see the below: image

Confirming in Azure DevOps...

4.Confirm in the Azure DevOps platform that the self hosted agent is running: image

Configuring your pipeline to use your self hosted agent:

  1. Next, you'll need to tell your pipeline that you want to use your self hosted agent.

  2. Locate azure-pipelines.yml in your repo on Azure: image

  3. Locate your pipeline and click the edit button: image

  4. Add the name of pool where your self hosted agent is located: image

  5. Click the Save button on the top right to save the pipeline.

An example run in action:

  1. Any changes to the main branch will trigger the pipeline to run. You don't need to keep the self hosted agent running... If the agent is not running the pipeline won't run. You can setup branch and pull request policies to control this.

Here is a side by side comparison (Docker: right, Azure DevOps: left) showing that the local agent was successful in running a pipeline: image

Issues ?

Open an issue