Agent is a server with the appropriate Operating System and the tools installed and configured.
Azure DevOps Supports below two agents :
- Microsoft agents – These Agents are totally manages by azure
- Self-Hosted Agents – These agents are configured by the user according to their needs.
- 1. Have a self-hosted agent just like the Microsoft-hosted agents
- 2. Automate the process as much as possible, and limit maintenance
- 3. Keep the self-hosted agent up to date when Microsoft updated their hosted agents
- 4. Automatically scale agents when usage increases or decreases to optimize on the "pay for what you use" idea
- 5. Be cheaper on a monthly basis than buying 5 Microsoft-hosted agents
In this Section We will see how to configure a self hosted agent for Windows And Linux VM
Creating a Personal Access Token (PAT)
Before We start configuring agents we need to create a PAT token.
Step 1. Login to Azure DevOps organization, open user settings, and select “Personal access tokens”
Step 2. In Personal Access Token Page, click on new token to Create the new token
Step 3. Provide the details Name of the token Expiration Date and permissions to this token
Note: Make sure to give full access for pipelines
Step 4. Once the token is generated, save it and use it in configuring agents.
Installing & configuring the agents
We have created the token so now we can start configuring the self hosted agents
Below are the steps to create a self hosted agents
Step 1. Navigate to the organization setting and then click on Agents pools.
Step 2. Select the Default Pool or You can create your own pool By clicking Add Pool
Step 3. Now Click on new agent and follow the steps mentioned in that
Step 4. You can select the desired operating system also
Windows Installation
Step 1. First Download the agent it will create a zip file
Step 2. Now extract the zip file to the target location( it is recommended to save in C: drive)
# Create directory and navigate to the directory
New-Item -Path “C:” -Name “agents” -ItemType “directory”
Set-Location -Path “C:agents”
# Extract the downloaded zip file
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory(“C:vsts-agent-win-x64-2.195.1.zip”, “$PWD”)
# Verify the extraction
Get-ChildItem
Step 3. Start configuring the agent by below command
.config.cmd
It will ask you some question which are mentioned below
- Enter the URL: https://dev.azure.com/{your-organization}
- Enter the authentication type (press enter for PAT) – Press enter for this step.
- Enter personal access token. – Paste the PAT generated earlier
- Enter Agent Pool – Press Enter if you are creating an agent in the default Agent pool, otherwise, provide the name of the Agent Pool
- Enter Agent Name – Provide the Agent Name
- Enter run agent as Service – Press Y for this in order to install & Run the Agent as a service in the Virtual Machine.
Step 4. Now Go back to the agent pool and now you can see the agent under the pool
Linux Installation
Installing and configuring the pipeline agent in Linux is similar to Windows. So, here we can see how to install Linux Agent
Step 1. Download the agent
wget https://vstsagentpackage.azureedge.net/agent/2.195.1/vsts-agent-linux-x64-2.195.1.tar.gz
Step 2. Create a folder and extract the downloaded tar.gz file.
# Create directory and navigate to the directory
mkdir agent
cd agent
# Extract the downloaded zip file
tar zxf ~/Downloads/vsts-agent-linux-x64-2.195.1.tar.gz
# Verify the extraction
ls
Step 3. Start configuring the giving below command
./config.sh
Similar to Windows configuration, the users will be asked to enter the server details, authentication type, and the authentication token we created earlier. Then configure the agent details, and finally, the user can start the agent by running the run.sh script.
Step 4 (Optional). You can configure the agent to run as a system service using the svc.sh script located in the agent directory. Specify the user and use the install command to configure the service.
sudo ./svc.sh install [user name]
sudo ./svc.sh start
Step 5. Now go back to the agent Pool and under this pool you will get the agent running
Add a Comment