Azure DevOps — Intro to Pipelines
One of the best offerings from Microsoft for DevOps teams at the moment is the Azure DevOps service. At the moment, Azure DevOps provides some services for free that are beneficial to onboard DevOps into workflows. Essentially, Azure DevOps is a collection of other tools used in the DevOps community.
For example, Azure DevOps Wiki and Board are similar to Atlassian’s Jira and Confluence. Azure Repos is similar to GitHub/GitLab/Bitbucket. Azure Pipelines is identical to Jenkins/GitLab-CI/TravisCI/etc.
In this post, I will quickly go over the Azure Pipelines feature of Azure DevOps. This post assumes that you are familiar with Git and SCM concept. If you would like information on Azure Repo or Git, then reach out to me or comment below.
We already have a project in our Azure Repo. This project was from the Net Ninja’s React Tutorial you can find on his YouTube channel and I recommend checking out his channel if you want to learn some new tech stacks on the web.
The first step is to create a pipeline in our project located in the Azure DevOps account. Click on the Pipelines in the sidebar and then ‘New Pipeline’. You will have a choice to select several repos. We won’t get into each one and assume Azure Repos Git.
Select the repository the code is in and the type of project. Since our project is a React application we will go with Node.JS.
The final screen will have some example code of a pipeline script as shown below
The script is basic and instructs that a VM-image running Ubuntu to be created. The VM is created in the Microsoft Azure’s tenant where they manage the VM. For those that are interested, the Microsoft hosted VM comes pre-installed with a lot of tools that are commonly used in configuring Dev/Stage/Prod servers to host many web application. This saves you the time on finding these packages and configuring them on the VM when you are building and testing out applications. Once a VM is ready then nodeJS 10.x is installed and our application is built. You can click on ‘Save and Run’ to save the azure-pipelines.yml file into your code repo. This will also execute your first pipeline run.
The default script is rather boring and simply builds the application. In CICD workflows, we tend to do more steps or tasks in the pipelines. One task is to deploy a built application. When a pipeline is executed, it should be assumed that the VM created is tossed away when the pipeline is completed (there are ways around this and we will see them in later posts). This helps to reduce costs and resources running in our environment. Once the build is complete, we can push the build into storage or sometimes refer to it as the build storage artifact.
We will need to clone or pull the current build onto our desktop and edit the azure-pipelines.yml file to add the following at the bottom:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(System.DefaultWorkingDirectory)/build'
artifactName: Website
You will notice that under the ‘steps’ section there is either ‘task’ or ‘script’. Tasks have a notation of name@number value. These are pre-defined tasks Microsoft has conveniently offered to help you construct pipelines. In our case, we will be using PublishBuildArtifacts@1 to save our build for later use.
Save the file and push it to the repo. Since we already have an azure-pipelines.yml file defined, the push will automatically trigger the pipeline build process now. Once the pipelines have been finished, we can now see our build in the artifacts that can be used in later projects.
Congrats, we now have a starting point of onboarding CICD into our project. In later posts, we will dive into building onto our basic pipeline to deploy and test our web application… LLAP