Welcome to Azure Devops! Azure DevOps can be a one-stop-shop platform for managing source code for applications. Here you can store your code, create automation pipelines, and deploy applications. In addition, you can run automated tests, and much more.
If this is your first time using Azure DevOps or want a refresher, this series of tutorials is for you. In brief, I’ll get you onboard the CI/CD process. To start with, you’ll learn how to create a repo for your code, where other developers can access it and make changes to it. By creating a build pipeline, you’ll be able to start the process of using CI/CD. This allows development teams to increase their working efficiency. This is through taking many of the manual tasks and having them automated.
In this series, you’ll create a repo and a YAML build pipeline first. Next, you’ll establish a release pipeline. Finally, you’ll be setting up quality assurance (QA) testing. These pipelines will be simple and get you familiar with the basics.
First, what is a repo?
What’s a Repo?
A repository or ‘repo’, is a centralized location where your application’s source code lives. This allows developers to make changes to it using version control tools, like Git or Azure DevOps.
Some management tools, like Git, enable both private and public collaborations. This is especially useful for both larger open-source projects and proprietary development. That said, Azure DevOps gives you formal support offerings, a plus in a business setting.
If you don’t use a repo, you’ll have difficulty organizing even smaller team projects. In essence, duplication occurs along with teams working on obsolete code. To stop these problems in your development process you must use a repo.
Let’s now dive into creating your first repo and linking it to a build pipeline.
Creating Your First Repo
The first thing you’ll do is create a new repo:
- Click repos on the left-hand menu.
- Go to the dashboard and select repos. A list of repos that are in your project will appear.
- Go to the bottom of the drop-down and select new repository.
- Once you click new repository, you’ll get a dialog box that asks what kind of repo you want–either Git or TFVC. Often, you’ll want to create a git repo unless your team lead directs you differently.
- Name your repo. In this case, you can call it ‘Test’, but you’ll want to follow your company’s naming conventions.
Once you click create at the bottom of the dialogue box you’re taken to your newly created repo. This is empty except for the automatically generated readme file and a Git ignore file if you chose to include one.
You’ve now successfully created a repo in Azure DevOps. Now for the next step, let’s create a build pipeline to go with this repo.
Create a Build Pipeline
Now that you have created your first repo, you’ll need to create a build pipeline. A build pipeline is going to take all the manual tasks that you need to compile and run your code.
The Compiled Program
This build pipeline will create an artifact; this is your compiled program. In general, this artifact will only be useful in your release pipeline. I’ll talk more about release pipelines in the next article.
Step 1: Creating the Build Pipeline
The first step to creating your build pipeline is quite simple. Right now, you should still be on your newly created repo. At the very top of the page, you should see a blue button that says “set up build”. Click it and this will take you to the next step.
Step 2: Configuring the Build Pipeline
In this step, you configure your pipeline. At this stage, you have two main options that are most commonly used. The “Starter pipeline” will provide you with a boilerplate YAML pipeline to get you started. For this tutorial, you’ll use this option for its setup convenience. Before we move on, though, it’s important to go over a few of the options provided with this option.
If you already have YAML pipelines, you can click on the second option “Existing Azure Pipelines YAML file”. This will allow you to import your pipelines or templates.
Step 3: Running the Build Pipeline
Once you click on “starter pipeline” you’ll get a YAML file with your starter pipeline as shown in the screenshot below.
When you click “save and run” you’ll need to make a commit to push to master to get your pipeline added. Once you do that you can run it; it’s that simple.
Now, let’s walk through the key “steps” you can change so you can optimize your YAML.
YAML allows you to add or change steps to optimize your workflow. In this section, I’ll provide you with the key steps you need to know. Firstly, let’s go through one of the most important ones.
This is what kicks off the pipeline’s workflow. The trigger is set to master in this example. Whenever a pull request (PR) is made to master, this pipeline will run.
Another useful step is “Pool”. This can be filled with many functions such as vmImage and pipeline agents. In this example, it’s pulling a base image for the latest Ubuntu operating system.
Steps in General
Above all else, you need to remember that “Steps” are the tasks the pipeline will execute. For example, the first script in this example will print “Hello World”. The “displayname” is the name of the task. You can see display names or task names in the console as the pipeline runs. The second script will print a message and a link to follow.
In this example, you can see how simple pipelines and steps are. So, congratulations! Now you can set up pipelines. This will be useful for all Azure DevOps you create in the future.
In this tutorial, you created your first repo and set up a build pipeline. This also allows you to create your project and automate any manual tasks. In addition, you became more familiar with YAML and how to read the code which makes up your pipeline.