Self-hosted Linux Agent on Azure DevOps in 5 minutes!!

Self-hosted Linux Agent on Azure DevOps in 5 minutes!!

Yes! you don't have to pay for Microsoft hosted Agents or get a new server to work/practice. Use your own Linux machine instead!

If you are like me and you want to learn Azure DevOps, you need a machine to build the code, perform releases etc. But I can't rent a server you say? You don't have to my Friend.

The process is same if you have a VM on Azure, an Azure VMSS or any Linux machine and want to use it as an Agent in your Azure DevOps.

Lets see how we can do that.

Prerequisite:

  • A Linux machine
  • Azure DevOps account.

1. Setting up the Agent Pool

Go to your Azure DevOps account -> Organization Settings, then Agent Pools in Pipelines

Click on Add Pool

image_1640860458242_0.png

Choose Self-Hosted, and give it a name and description

image_1640860546091_0.png

You can choose to grant access permissions to specific pipelines too. Uncheck the option if needed.

Open the created Agent pool and click "Agents" then "New Agent"

Choose Linux and "x64" which is what many use these days. You can also choose RHEL6 or other ARM architectures if needed

image_1640860832895_0.png

2. Installing the Agent

Check the download location of your file just to be sure. I have mine in Downloads

Change your working directory to Downloads using cd Downloads in your terminal Then make a new Directory and change directory into it using mkdir myagent && cd myagent

Use tar zxvf ~/Downloads/vsts-agent-linux-x64-2.195.2.tar.gz check the version. Instead you can use the command you are presented by Azure DevOps

image_1640861967419_0.png

Run ./config.sh and Y after you check the Agreement.

image_1640862752768_0.png

The Server URL is dev.azure.com/YourOrganizationName find it on your Azure DevOps

Press "Enter" as we are going to use the PAT token to authenticate.

3. Generating a PAT token

For the PAT token go to your Azure DevOps Account

image_1640862180783_0.png Click "New Token"

image_1640862257448_0.png

Give the token a name and Full access. You can choose your custom defined scope if you know what you wont be needing.

Create a New token. This token once disappeared cannot be retrieved later. So make sure you copy it just in case you need it later.

image_1640862798717_0.png

4. Final steps

Enter the Agent pool Name which is "newAgent" for me and a name for your Agent. R2D2 in my case.

image_1640862568733_0.png

Next run ./run.sh

image_1640863163559_0.png

5. Enjoy!

Now check your Agents and there we have it, our new Agent up and running image_1640863217411_0.png

Thank you for Reading you can find me on Twitter or read my blogs on Hashnode and Medium