Tuesday, July 13, 2021

Create Self Hosted Agent for Azure Pipelines

  

1. Create an Account on Azure DevOps

Navigate to  the Url https://azure.microsoft.com/en-in/services/devops/ login with your Microsoft Account or create new one .



2. Create an Organization 

Click on New Organization give name for the Organization click continue 



3. Create a New Project

For creating a new project click on the New Projectgive the project name and select private or public depending on the requirement and click Create button. You can push the code to the created project repository !

4. Setting Up  Self Hosted Agent ( Personal computer / VM )

Go to Organization settings => Agent Pools => click on Add Pool ,you can setup the agent in the existing default pool also . select pool type as self -hosted 
give a name for the pool and click create button 




your pool will be listed with the existing pools with the given name .
 


 click on the pool => click New Agent => click Download the Agent 
create an Agent folder in the PC and extract the zip file in the Agent folder.


For setting up the agent you need  PAT ( Personal Access Token) , for that go to User Settings => click personal access token 



Enter the  details to generate the  token and store it some where 


Open PowerShell with administrator access and execute the command 

PS C:\WINDOWS\system32> cd C:\Agent
PS C:\Agent> .\config.cmd


1. you need to  give the Server URL : https://dev.azure.com/<ORGANISATION NAME>

2. Enter the   Personal Access Token

3. Enter  the  name of the agent pool that we created 

4. Enter a name for the agent 

5.  Give No  if you don't want to run it as a service .


Agent is created . You can double click run.cmd for  making it as online you can give the  name of Agent in the Yaml file or the classic editor for using it .

Example 

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:  LocalPool


variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

No comments:

Post a Comment