Azure Devops - Create a CI / Build Pipeline
In this article, we will cover how to add new pipeline to Devops project.
Go to https://dev.azure.com/. Sign in with your credentials.
Open the Devops Organization and Open the listed project. To understand, how to create Devops Organization and project, Go to my previous article.
Please see the below image for more understanding.
Go to Pipelines in the left menu. Click on New Pipeline.
This screen will appear.
There are two ways to create pipeline One way is using classic editor and other is using yaml code. classic editor is the way of creating pipelines as was done in TFS earlier.
YAML is configuration language similar to JSON. DevOps provides many YAML templates to create pipeline. We will use here YAML pipeline for ASP.net core project.
Choose Azure Repos Git as we have already uploaded the code in Azure Repos in our previous article.
Select the repository. Then this screen will appear.
These are defined templates for azure pipeline. We will choose ASP.Net Core (.Net Framework) here.
This screen will show the yaml code for the pipeline.
This line indicates that this pipeline will be triggered when there is any changes commited to main branch of this repository.
trigger:
- main
This line indicates that the latest windows image will be picked up.
pool:
vmImage: 'windows-latest'
This line indicates the variables and other build information.
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
After this there are steps and its tasks like NuGetInstaller command and restore. There is build task.
- 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)'
We will remove the highlighted Test task in the above image, as we do not have a test project in our solution. Also, If required we can add new tasks to YAML from the right menu shown under Tasks. One example could be the ARM template. If we have an ARM project in our code then we can add the additional task for the configuration of ARM deployment. We will not add any tasks and keep it simple for now. Press Save and Run.
Azure pipelines. yaml file is committed to the code. The pipeline is created. This will be executed on the Azure pipelines agent as shown below. Azure Pipelines agent is the agent hosted on the Azure server. If we want we can create self-hosted agent as well.
The Top job on the screen is the job served by this agent from azure.
Comments
Post a Comment