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
- Click New pipeline
- click Azure Repos Git on where is your code? pane
- click on the project name under select a repository pane
- Select Existing Azure Pipelines YAML File under Configure your pipeline pane.
- Change the branch name to main and choose a path for your template e.g /.ado/eshoponweb-ci-pr.yml
- Click continue
- Examine the YAML file and click the down arrow beside Run button to save the YAML file. 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.
- Select +New Token
- Give the name to the token, select Agent pools scope and choose Read and manage permission, click create after.
- Copy the token in the success pane for future use.
- 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.
- Select Agent pools under pipeline section and click Add pool.
- Select Self-hosted in the pool type dropdown, give a name to the agent pool and click create
- Click on the the newly created agent pool in the Agent pools pane to open it.
- Select New agent under Job tab
- 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.
- Open the powershell console by clicking start button and search for powershell. Select the powershell.
- 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")
- We are to configure the agent with this command in the powershell console .\config.cmd
- 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.
- 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.
- Go back to your project by clicking DevOps symbol and select the project.
- Click pipelines in the pipelines section.
- Click on your pipeline to open it
- Click Edit
- Replace vmImage: windows-latest under pool with the agent pool created.
- Click save Click save in the save pane
- Click Run
- Click Run in the Run pipeline pane
- Click pipelines to see the the pipeline that is running and click view to grant permission
- Click permit in waiting for review pane
- Select permit
- Monitor the job until it is successful
- 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.
Top comments (1)
Welldone!