DEV Community

Cover image for Configuring Self-Hosted Agent and understanding pipeline styles the easiest way.
Olalekan Oladiran
Olalekan Oladiran

Posted on

Configuring Self-Hosted Agent and understanding pipeline styles the easiest way.

How to create an Azure DevOps YAML pipeline

We will learn how to create a template based YAML pipeline in Azure DevOps.

  • Open your project by clicking on it.
  • Click on Pipelines Image description
  • Click New pipeline Image description
  • click Azure Repos Git on where is your code? pane Image description
  • click on the project name under select a repository pane Image description
  • Select Existing Azure Pipelines YAML File under Configure your pipeline pane. Image description
  • Change the branch name to main and choose a path for your template e.g /.ado/eshoponweb-ci-pr.yml Image description
  • Click continue Image description
  • Examine the YAML file and click the down arrow beside Run button to save the YAML file. Image description Note that this will only create pipeline without running it.

How to set up an Azure DevOps agent pool.

  • in your project project, click User settings at the upper right corner and select personal access tokens. Image description
  • Select +New Token Image description
  • Give the name to the token, select Agent pools scope and choose Read and manage permission, click create after. Image description
  • Copy the token in the success pane for future use. Image description
  • Go back to the organization by clicking Azure DevOps symbol in the upper left corner and then click organization settings in the lower left corner. Image description
  • Select Agent pools under pipeline section and click Add pool. Image description
  • Select Self-hosted in the pool type dropdown, give a name to the agent pool and click create Image description
  • Click on the the newly created agent pool in the Agent pools pane to open it. Image description
  • Select New agent under Job tab Image description
  • Make sure that Windows and x64 tabs are chosen in the Get the agent pane and select Download. A zip archive containing the agent binaries will be downloaded your local download folder. Image description
  • Open the powershell console by clicking start button and search for powershell. Select the powershell. Image description
  • Run this command to create a directory called agent, change the directory to agent and also extract the archive file downloaded

cd \mkdir agent ; cd agent

Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$HOME\Downloads\vsts-agent-win-x64-3.234.0.zip", "$PWD")
Image description
Image description

  • We are to configure the agent with this command in the powershell console .\config.cmd

Image description

  • Enter server URL: the URL of your Azure DevOps organization, in the format https://dev.azure.com/organization_name, where organization_name represents the name of your Azure DevOps organization.
  • Enter authentication type (press enter for PAT): Enter.
  • Enter personal access token: The access token you recorded earlier in this task.
  • Enter agent pool (press enter for default): az400m03l03a-pool.
  • Enter agent name: az400m03-vm0.
  • Enter work folder (press enter for _work): Enter.
  • (Only if shown) Enter Perform an unzip for tasks for each step.
  • (press enter for N) WARNING: only press Enter if the message is shown.
  • Enter run agent as service? (Y/N) (press enter for N): Y.
  • enter enable SERVICE_SID_TYPE_UNRESTRICTED (Y/N) (press enter for N): Y.
  • Enter User account to use for the service (press enter for NT AUTHORITY\NETWORK SERVICE): Enter.
  • Enter whether to prevent service starting immediately after configuration is finished? (Y/N) (press enter for N): Enter. Image description
  • After configuring the agent, go back to your DevOps portal, change the tab to Agent and you will see your newly configured agent with online status. Note that if your Agent is displaying offline, you can change the status to online with this command: .\run.cmd in the Agent directory of the powershell. Image description
  • Go back to your project by clicking DevOps symbol and select the project.
  • Click pipelines in the pipelines section. Image description
  • Click on your pipeline to open it Image description
  • Click Edit Image description
  • Replace vmImage: windows-latest under pool with the agent pool created. Image description
  • Click save Image description Click save in the save pane Image description
  • Click Run Image description
  • Click Run in the Run pipeline pane Image description
  • Click pipelines to see the the pipeline that is running and click view to grant permission Image description
  • Click permit in waiting for review pane Image description
  • Select permit Image description
  • Monitor the job until it is successful Image description
  • If you click on the job to open the view raw log, You will see it run with the the pool and Agent we created. Image description

Top comments (1)

Collapse
 
rdgmh profile image
Raphael Gab-Momoh

Welldone!