Azure DevOps | Setting up self-hosted Build Agent
Title: Azure DevOps | Setting up a Self-Hosted Build Agent
Introduction: Azure DevOps is a powerful platform that provides a wide range of tools and services for software development and delivery. One of the key features of Azure DevOps is the ability to run build and release pipelines to automate the build, test, and deployment processes. While Azure DevOps offers its own hosted build agents, there are scenarios where you might need to set up a self-hosted build agent to meet specific requirements. In this blog post, we will explore the process of setting up a self-hosted build agent in Azure DevOps.
Prerequisites: Before we dive into the setup process, there are a few prerequisites that you need to fulfill:
An Azure DevOps account: You should have an active Azure DevOps account to access the necessary features and services.
An Azure virtual machine or an on-premises machine: You will need a machine to host the self-hosted build agent. It can be a virtual machine in Azure or a physical machine in your on-premises environment.
Step 1: Create a Personal Access Token (PAT) To authorize the self-hosted build agent to communicate with Azure DevOps, you need to create a Personal Access Token. Follow these steps to create a PAT:
Go to your Azure DevOps account and navigate to the "User Settings" page.
Click on "Personal Access Tokens" and then "New Token."
Provide a name for your token, choose the desired organization, and select the appropriate scope for the token (e.g., Agent Pools, Build, and Read).
Click on "Create" and make a note of the generated token. You will need it during the agent setup.
Step 2: Download and Configure the Build Agent Next, you need to download and configure the self-hosted build agent on your machine:
Open the Azure DevOps portal and navigate to the "Agent Pools" page.
Click on "New Agent" to download the agent package.
Extract the downloaded package on your machine.
Open a terminal or command prompt and navigate to the extracted agent folder.
Run the configuration script using the following command:
Provide the requested information, such as the URL of your Azure DevOps organization and the PAT you generated earlier.
Select the agent pool where you want to register the agent.
Choose a unique name for the agent and specify any additional configuration options as needed.
Save the provided settings, and the agent will be configured and registered with Azure DevOps.
Step 3: Start the Build Agent Once the agent is configured and registered, you need to start it to make it available for running build and release pipelines:
In the terminal or command prompt, navigate to the agent folder.
Run the following command to start the agent:
The agent will start and establish a connection with Azure DevOps.
You can verify the agent's status in the Azure DevOps portal under the corresponding agent pool.
Step 4: Configure Pipelines to Use the Self-Hosted Agent Now that the self-hosted build agent is up and running, you can configure your pipelines to utilize it:
Open your Azure DevOps project and navigate to the pipeline that you want to modify.
Edit the pipeline configuration and find the agent specification.
Change the agent specification to specify the agent pool and agent name that you set up in Step 2.
Save the pipeline changes, and it will now utilize the self-hosted build agent for its execution.
Conclusion: Setting up a self-host