An Introduction to Microsoft Azure DevOps
Introduction
In this article I will give you an introduction to DevOps and how to use Microsoft Azure DevOps to build, test and release your software.
I will use an Android app written in Kotlin as the example, but most of the things I write about is applicable to other types of solutions.
We at Avalon Innovation are more than 250 specialists all over Scandinavia who are passionate about developing ground-breaking, innovative product and system solutions that really make a difference. Since 1997 we have tackled many challenging and difficult assignments, which have provided us with broad technical expertise and unique insights into innovation.
What is DevOps?
Donovan Brown is a Principal DevOps Manager at Microsoft and defines DevOps this way.
"DevOps is the union of people, process, and products to enable continuous delivery of value to our end users."
From a more technological standpoint, DevOps is a combination of development methods and operation methods to shorten the development lifecycle and aims to deliver software with high quality more frequently.
A DevOps tool like Microsoft Azure DevOps usually includes features like scrum/kanban boards, code repos, build and test tools (Continuous Integration) and release tools (Continuous Delivery).
Getting Started
The easiest way to get started is to go to the Azure DevOps portal (https://azure.microsoft.com/en-us/services/devops/) and start a free account. Just sign in with your Microsoft account (or create a new one) and sign up for a free Azure DevOps environment.
In a matter of minutes you will be able to start to explore Azure DevOps!
Boards
Azure DevOps includes all you need to manage your DevOps project and the Boards section supports both the Scrum process as well as Kanban.
This article will not focus on Boards, but try it out! It really has all that you need.
Repos
It will make your life a bit easier if you place your git repos in Azure DevOps, but if it's not possible to move your code at the moment, the build and release tools can integrate with other platforms like GitHub.
If you decide to move your code Azure DevOps has all the git features you need.
Pipelines
The build and release pipelines are what I will focus on in this article.
A build pipeline defines all tasks that are involved in building, testing and packaging your software.
A release pipeline defines the end-to-end process of deploying your software.
Builds - Continuous Integration (CI)
CI is the process of automating building and testing of code every time someone commits a change to the repo.
A build pipeline consists of tasks to be executed and what tasks we use depends on the technology used in the software.
I will now guide you on how to create a new build pipeline for an Android app that will build the code, run the tests and package the app to an artifact that can later be released.
Start by selecting the Builds meny and then click on New -> New build pipeline. This will start the process of creating a new build pipeline.
The next step is to select the code repository where the source code is. In my case it's in Azure DevOps in a repo called "KotlinMotorcycles" and I will fetch the code from the master branch. Click Continue!
Either we select to use the YAML language to define the build pipeline or we select a template that matches the solution.
In my case I select Android, because this is an Android app and I prefer to use the visual task configuration tool. Select and click Apply!
Now this is the main editing view of a build pipeline! If you select Pipeline as in the image above you can change the agent pool used to build your software. Microsoft hosts a number of build agents for you on Windows, Linux and macOS, but you can also define your own build agents on your own hardware if you like.
If you select Get sources you can change settings about your code repo and beneath that is a list of tasks that will be run when the build job is run.
Each type of task has its own set of settings that sometimes is mandatory to fill out and sometimes are optional.
Click the + button to add a new task.
Here you can select from a vast number of build tasks, testing tasks, packaging tasks and tools for running scripts. It even has a marketplace where you can download tasks and extend your Azure DevOps environment!
Click on the top menu Triggers! This is where you can turn on CI! When turned on, this build job will run every time someone commits changes to the branch you selected.
You can also schedule builds or make this build job run after another build job completes to create a chain of build jobs.
When your done select Save & queue to run your build job for the first time!
Now the job is running! Click on the link to follow the process.
If one of the tasks/steps fails then click on the step to read the log output and try to find out why it was failing. It could be a faulty setting or that a test failed.
After a couple of minutes the build is done.
Success! If I click on the gradlew build task and scroll down to the bottom I can see that the build was successful and the tests has been run.
This is what you want to see! Lets follow the link and view the test results.
All 8 tests has been run successfully! Great!
The result of a build is called an Artifact and that is your built and packaged software that is now available to be deployed when you want to. This we will look at in the next section.
Releases - Continuous Delivery (CD)
CD is the process of delivering a built and packaged artifact to the users.
The deployment destination can be your own server, a hosted app in the cloud somewhere or more or less any place. I will deploy my app to Microsoft App Center. I will cover App Center in another article, because it has a lot more great features than just distributing mobile apps.
Start by selecting the Releases meny and then click on New -> New release pipeline. This will start the process of creating a new release pipeline.
Just like when we created a build pipeline, you get to select a template to get started, but there actually aren't a template for App Center so I just select to create an empty pipeline.
This is the main view for a release pipeline. To the left you can select an artifact to base the release on, beneath that you can select to schedule releases and to the right you define your stages.
Stages is the tool to use to move software to different audiences. You can for example define stages for development, QA and production where every stage represents is an environment for a certain audience. The dev environment is perhaps only used for testing by your own team, QA for external testing and production for released software. Azure DevOps helps you to move an artifact between the stages in a controlled manner.
Click on Add an artifact. In this case we select to get the artifact from a build pipeline, select the pipeline and then click Add. There are other options on how to fetch an artifact. Please explore!
Click on Schedule not set. This is where you can schedule your releases! Often you want to do a nightly release to dev or QA and this is how you do that.
Click on 1 job, 0 task in the stage box to define the tasks involved in the stage. In my case I added a Deploy to App Center task and connected it to my App Center account.
Lets create a release! Click on the meny Release -> Create a release at the top of the screen.
This screen pops up where you select the stage and then click on Create.
The release was created! Click on the link.
The release has been created, but not deployed yet. Move your mouse over the stage and click on the button Deploy that will appear.
Click Deploy.
It will work for a while...
Success! The deployment is complete!
Conclusions
I hope you enjoyed this short introduction to Microsoft Azure DevOps! There are a lot more features to explore and I hope you got inspired to do so.
Microsoft Azure DevOps makes it easy for us to work with boards, code repos, automatic build, automatic tests and automatic deployments. It is a complete solution for DevOps teams and does the job well!
Happy Coding! :-)
DevOps is an approach to software development that enables better collaboration between the development and the operations teams. Basically, it is a methodology that aims to bridge the gap between developers and operations during software development to facilitate a more productive and efficient workflow. Sample Copy : http://bit.ly/2TKsB0Q