Adding self-hosted Linux agent in Azure DevOps
2 min read
In this article, we are going to add a Linux machine as an agent to build our Azure pipelines.
Azure DevOps + Linux Machine
The process is the same if you have a VM on Azure, a VM on your laptop or any Linux machine and want to use it as an Agent in your Azure DevOps.
Let's see how we can do that.
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
Choose Self-Hosted, and give it a name and description
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
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 the 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
Run ./config.sh and Y after you check the Agreement.
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
Click “New Token”
Give the token a name and Full access. You can choose your custom-defined scope if you know what you won't 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.
4. Final steps
Enter the Agent pool Name which is “newAgent” for me and a name for your Agent. R2D2 in my case.
Next run ./run.sh
Now check your Agents and there we have it, our new Agent up and running