Create & Build CI/CD Pipelines with Azure DevOps — Part 1
Creating a Build Pipeline
Azure DevOps Starter provides a streamlined procedure for setting up a continuous integration (CI) and continuous delivery (CD) pipeline to Azure. You can choose an example application or use your code and Git repository.
Prerequisites — Azure DevOps
Make sure you have the following items:
- An Azure subscription.
- Access to a GitHub or external Git repo that contains program code [In our sample, we have a source code in Azure Repo].
- An Azure DevOps team. If your company already has a dedicated team, make sure you’re an administrator of the Azure DevOps project you want to use.
- The ability to run pipelines on Microsoft-hosted agents. You can purchase a similar job or request a free tier.
This blog will explain how to configure the CI/CD Pipeline. It is best demonstrated with an example of an Azure function app deployment. Here is the quick step-by-step process to create a new pipeline to build and release in Azure App Service.
Create a Build Pipeline (CI/CD):
- Create a pipeline and select the ASP.NET template. This selection automatically adds the tasks required to build the code in the sample repository.
- Save the pipeline and queue a build to see it in action.
- Create a release pipeline and select your stage’s Azure App Service Deployment template; this automatically adds the necessary tasks.
- Link the build pipeline as an artifact for this release pipeline. Save the release pipeline and create a release to see it in action.
Step-By-Step Procedures to Create a Build Pipeline
To create a build pipeline, choose Pipeline from the left menu and click on Create Pipeline or New Pipeline if it exists as shown.
After clicking on the Pipeline option from the menu, you will see a dashboard with an existing list of built pipelines. Build pipeline is the toolchain that collects the latest changes from the repository and the branch and creates a package to a location that can later pick up the release pipeline. There is the option of creating a new pipeline, or you can open the existing one from the list. I chose the option to create a new build pipeline.
I chose Azure Repos Git for collecting the latest changes; it will come with a list of pre-configured options for choosing a repository and source control system. Below is the first screen:
Azure DevOps needs to know the repository address, so it can check the latest code to generate a build package for your deployment pipeline. So we chose the other option of opening Classic Edition where you can choose the repo, project, and branch.
In our sample, we have our repository in the Azure Git repo.
Click on Continue and choose the ASP.NET template.
We are also provided with an Empty Job, where we can add our custom tasks from basics, but Azure pipeline provides various templates to make our job easier.
The Agent Job was created for our task. By default, all pipelines use Azure pipelines as Agent pools. Agent specification is based on the build Operating system, and we use Windows-2019 based on our solution. NuGet packages and other necessary libraries for the build are imported from Nuget restore.
Drop is the folder in which the build artifacts are stored for release.
Build Solution is where the solution and its projects get to build and generate the build binaries. Build platform and Build configuration are set to any CPU and released in pipeline variables. The Clean checkbox is selected for clean and rebuild on every build. Publish Artifact will store them under the Drop folder, from where it is moved to release folders.
Another option is to enable/disable the continuous integration trigger. Whenever there is a check-in, the repository’s files will automatically kick the build to generate artifacts with the latest changes.
Click Save, Save, Queue, Draft, and Discard for the changes you are making and how you want to run it after making those changes.
Once the Run pipeline is saved and runs, it starts processing the build.
You can get more detailed with steps to analyze what has been changed with each build, and you can then open the drop location where artifacts have been placed, and check the file list if any verification is required.
Below are the detailed tasks to execute the build:
Now the job is completed successfully, the artifacts are published in the respective folder, and it can be verified from Related work items.
DevOps methodology’s foundation is CI/CD, which unites teams from IT operations and development to deploy software. The speed at which code can be published has evolved into a competitive differentiator as custom applications become essential to how businesses differentiate themselves.
Talk to our experts at Payoda Technologies today to learn more about building CI/CD pipelines to maximize your business impact.
We will post part 2 of this blog explaining how to create Azure DevOps release configurations step by step, so visit our blog again soon.