4 - Continous - Integration - Using - Classic - Build - Pipeline-Cicd Docs
4 - Continous - Integration - Using - Classic - Build - Pipeline-Cicd Docs
Azure Pipelines is a cloud service that you can use to automatically build, test, and deploy your code
project. It is a fully featured continuous integration (CI) and continuous delivery (CD) service.
Before you use continuous integration and continuous delivery practices for your applications, you must
have your source code in a version control system. Azure Pipelines integrates with GitHub, GitHub
Enterprise, Azure Repos Git & TFVC and Bitbucket Cloud.
You can automate the build, testing, and deployment of your code to Microsoft Azure, Google Cloud
Platform, or Amazon Web Services or On-Premise also.
You can use many languages with Azure Pipelines, such as Python, Java, JavaScript, PHP, Ruby, C#, C++,
and Go.
Use Azure Pipelines to deploy your code to multiple targets. Targets include container registries, virtual
machines, Azure services, or any on-premises or cloud target.
To produce packages that can be consumed by others, you can publish NuGet, npm, or Maven packages to
the built-in package management repository in Azure Pipelines. You also can use any other package
management repository of your choice.
Agent:
A build agent builds or deploys the code. When your build or deployment runs, the system begins one or more
jobs. An agent is installable software that runs one build or deployment job at a time.
Microsoft Hosted Agent: Each time we run a pipeline, we'll get a fresh virtual machine. There are six virtual
machine images to choose from, including Ubuntu 16.04 and windows 2019.
1
Deccansoft Software Services H.No: 153, A/4, Balamrai, Rasoolpura, Secunderabad-500003 TELANGANA,
NDIA. http://www.deccansoft.com | http://www.bestdotnettraining.com
Phone: +91 40 2784 1517 OR +91 8008327000 (INDIA)
Azure DevOps – Deccansoft Software Services Azure Build Piplines
Pipeline:
A pipeline defines the continuous integration and deployment process for the app. It's made up of one or
more stages. It can be thought of as a workflow that defines how your build, test, and deployment steps are
run.
The pipeline runs when you submit code changes. You can configure the pipeline to run automatically, or you
can run it manually. You connect your pipeline to a source repository like GitHub, Bitbucket, or Subversion.
Run
A run represents one execution of a pipeline. It collects the logs associated with running the steps and the
results of running tests.
Trigger
A trigger is something that's set up to tell the pipeline when to run. You can configure a pipeline to run upon a
push to a repository, at scheduled times, or upon the completion of another build. All of these actions are
known as triggers.
Build Artifacts
An artifact is a collection of files or packages published by a run. Artifacts are made available to subsequent
tasks, such as distribution or deployment.
The final product of the build pipeline is a build artifact. Think of an artifact as the smallest compiled unit that
we need to test or deploy the app. For example, an artifact can be:
A Java or .NET application packaged into a .jar or .zip file.
A C++ or JavaScript library.
Docker image.
Benefits of Continuous CI
Integration Continuous Integration (CI) provides many benefits to the development process, including:
Improving code quality based on rapid feedback.
Triggering automated testing for every code change.
Reducing build times for rapid feedback and early detection of problems (risk reduction)
Better managing technical debt and conducting code analysis.
Reducing long, difficult, and bug-inducing merges.
Increasing confidence in codebase health long before production deployment.
Here are the steps that happen during the build process:
1. Print build info to the wwwroot directory to help the QA team identify the build number and date.
echo date > ./wwwroot/buildinfo.txt
2. Run dotnet restore to install the project's dependencies.
dotnet restore
3. Run dotnet build to build the app under both Debug and Release configurations.
dotnet build --configuration Debug #Is used for debugging purpose so that we can get detailed
messages/errors.
dotnet build --configuration Release #Is used in Production. Its performance is better.
4. Run dotnet publish to package the application as a .zip file and copy the results to a network share for
the QA team to pick up.
dotnet publish --configuration Debug --output /Debug
dotnet publish --configuration Release --output /Release
This table associates the script commands with the new Azure Pipelines tasks:
Script command Azure Pipelines task
echo `date` CmdLine@2 or script
dotnet restore DotNetCoreCLI@2
dotnet build DotNetCoreCLI@2
dotnet publish DotNetCoreCLI@2
Create a Pipeline
1. Pipeline New Pipeline Use the classic editor
2. Select your Source Code Repository and Branch Continue
3. Select a Template: Select ASP.NET Core Apply
4. This generates all the Tasks in a Job.
5. (Optional) Add Task: File Creator to create a file
File path = ./HelloWorldApp.Web/wwwroot/buildinfo.txt,
Content = "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)"
6. (Optional) Add a Task: Command line Add
Script = echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)"
7. Click on Save and queue
Once the Pipelines completes the task – Check the Artifacts or check for the error.
Note: Check your email. You might have already received a build notification with the results of your run. You
can use these notifications to let your team members know when builds complete and whether each build
passed or failed.
4
Deccansoft Software Services H.No: 153, A/4, Balamrai, Rasoolpura, Secunderabad-500003 TELANGANA,
NDIA. http://www.deccansoft.com | http://www.bestdotnettraining.com
Phone: +91 40 2784 1517 OR +91 8008327000 (INDIA)
Azure DevOps – Deccansoft Software Services Azure Build Piplines
You also don't want builds to be triggered by changes to files in the tools folder.
Batch changes
Select this check box if you have many team members uploading changes often and you want to reduce the
number of builds you are running. If you select this option, when commits are made when a build is already
running, the system waits until the build is completed and then queues another build of all changes that have
not yet been built.
5
Deccansoft Software Services H.No: 153, A/4, Balamrai, Rasoolpura, Secunderabad-500003 TELANGANA,
NDIA. http://www.deccansoft.com | http://www.bestdotnettraining.com
Phone: +91 40 2784 1517 OR +91 8008327000 (INDIA)
Azure DevOps – Deccansoft Software Services Azure Build Piplines
choose to extract the parameters from the encapsulated tasks as configuration variables, and abstract the rest
of the task information.
6
Deccansoft Software Services H.No: 153, A/4, Balamrai, Rasoolpura, Secunderabad-500003 TELANGANA,
NDIA. http://www.deccansoft.com | http://www.bestdotnettraining.com
Phone: +91 40 2784 1517 OR +91 8008327000 (INDIA)
Azure DevOps – Deccansoft Software Services Azure Build Piplines
9. Select one of the bars to drill down into that build.
To display more widgets, select the Extension Gallery link at the bottom of the Add Widget pane.
7
Deccansoft Software Services H.No: 153, A/4, Balamrai, Rasoolpura, Secunderabad-500003 TELANGANA,
NDIA. http://www.deccansoft.com | http://www.bestdotnettraining.com
Phone: +91 40 2784 1517 OR +91 8008327000 (INDIA)