Reader small image

You're reading from  Azure DevOps Explained

Product typeBook
Published inDec 2020
PublisherPackt
ISBN-139781800563513
Edition1st Edition
Tools
Concepts
Right arrow
Authors (3):
Sjoukje Zaal
Sjoukje Zaal
author image
Sjoukje Zaal

Sjoukje Zaal is head of the Microsoft Cloud Center of Excellence, Microsoft Regional Director, and Microsoft Azure MVP with over 20 years' experience in architecture, development, consultancy, and design-related roles. She currently works at Capgemini, a global leader in consultancy, technology services, and digital transformation. She loves to share her knowledge and is active in the Microsoft community as a co-founder of the user groups Tech Daily Chronicle, Global XR Community, and the Mixed Reality User Group. She is also a board member of Azure Thursdays and Global Azure. Sjoukje is an international speaker and is involved in organizing many events. She has written several books and writes blogs.
Read more about Sjoukje Zaal

Stefano Demiliani
Stefano Demiliani
author image
Stefano Demiliani

Stefano Demiliani is a Microsoft MVP on Business Applications and Azure, MCT, Microsoft Certified Solution Developer (MCSD), Azure Certified Architect, and an expert in other Microsoft related technologies. His main activity is architecting and developing enterprise solutions based on the entire stack of Microsoft technologies (mainly focused on ERP and serverless applications). He has worked with Packt Publishing on many IT books related to Azure cloud applications and Dynamics 365 Business Central and is a frequent speaker at IT conferences around Europe. In his free time Stefano is also a runner and a cyclist.
Read more about Stefano Demiliani

Amit Malik
Amit Malik
author image
Amit Malik

Amit Malik is an IT enthusiast and technology evangelist from Delhi, India. He specializes in Virtualization, Cloud, and emerging technology space. He has an intense knowledge in building cloud solutions with Microsoft Windows Azure Pack. Amit holds various industry admired certifications from all major OEM's in Virtualization and Cloud space including MCSE for Private Cloud. Amit has designed and built numerous virtualization and private cloud solutions comprising the product lines of Microsoft, VMware, and Citrix. Apart from these, he can be found working on emerging technologies including VDI, hyper convergence, Software Defined Infrastructure solutions including networking and storage, Containers, Big Data, IoT, and other similar technologies. Amit is interested in building products and doing product management in near future for related technology space. You can always reach Amit on LinkedIn (https://in.linkedin.com/in/amitmalik99)or email (contact2amitmalik@gmail.com)
Read more about Amit Malik

View More author details
Right arrow

Chapter 3: Source Control Management with Azure DevOps

Source control management (SCM) is a vital part of every company that develops software professionally, but also for every developer that wants to have a safe way to store and manage their code.

When working in teams, it's absolutely necessary to have a safe central repository where all your code is stored. It's also necessary to have a system that guarantees that the code is safely shared between developers and that every modification is inspected and merged without raising conflicts.

In this chapter, we'll learn how Azure DevOps can help with managing source code professionally and securely. In this chapter, we'll cover the following topics:

  • Understanding source control management
  • Branching strategies overview
  • Handling source control with Azure DevOps and Repos
  • How to work with commits, pushes, and branches
  • Working with pull requests
  • Handling a pull request
  • How to tag...

Technical requirements

To follow this chapter, you need to have an active Azure DevOps organization and Visual Studio or Visual Studio Code installed on your development machine.

Understanding SCM

Source control (or version control) is a software practice used to track and manage changes in source code. This is an extremely important practice because it permits to maintain a single source of code across different developers and helps with collaborating on a single software project (where different developers works on the same code base).

SCM is an essential practice in any DevOps process. To adopt a source control policy, you should do the following:

  • Select a source control management system to adopt (for example, install Git on a server or use a cloud-based SCM such as Azure DevOps Repos or GitHub)
  • Store your code base in a repository managed by your source control management system
  • Clone the repository locally for development by taking the latest code version (pull) stored in the central repository
  • Commit and push your released code to the central repository
  • Use different copies of the repository for developing in a parallel way...

Exploring branching strategies

A branch is a version of your code stored in an SCM system. When using SCM with Git, choosing the best branching strategy to adopt for your team is crucial because it helps you have a reliable code base and fast delivery.

With SCM, if you're not using branching, you always have a single version of your code (master branch) and you always commit to this branch:

Figure 3.4 – One flow

This "one flow" way of work is not recommended because it cannot guarantee that the master branch is stable, especially if you have more than one developer working on the same code.

There are different branching workflows (strategies) that you can adopt for your team, and the recommendation that normally I suggest is to start simple. With Git, there are three main branching strategies that you can adopt:

  • GitHub Flow
  • GitLab Flow
  • Git Flow

In the following sections, we'll explore each of these strategies...

Handling source control with Azure DevOps

Azure DevOps supports the following source control management types:

  • Git: This is a distributed version control system and is the default version control provider in Azure DevOps when you create a new project.
  • Team Foundation Version Control (TFVC): This is a centralized version control system where developers have only one version of a file locally, data is stored on a server, and branches are created on the server (path-based).

The first step when working with Azure DevOps is to create a new project inside your organization. When you create a new project with Azure DevOps, you're prompted to choose the version control system you want to use (shown in the red box in the following screenshot):

Figure 3.8 – Create new project

By clicking the OK button, the new project will be created in your Azure DevOps organization.

Once the project has been provisioned, you can manage your repositories...

Working with pull requests

Pull requests allow you to notify your team members that a new implementation has been completed and must be merged with a specified branch. By using pull requests, members of your team can review your code (by stepping through files and see the modifications that a particular commit introduces), provide review comments on minor issues, and approve or reject those modifications. This is the recommended practice to use when using source control management with Azure DevOps.

You can view the incoming pull requests for a specific repository on Azure DevOps by selecting the Pull requests menu from the Repos hub, as shown in the following screenshot:

Figure 3.49 – Pull requests view

You can also filter this list to view only your pull requests or only the Active, Completed, or Abandoned pull requests.

A pull request can be created in different ways, as follows:

  • Manually from the Azure DevOps pull request page
  • From...

Handling a pull request

All the different ways to handle a pull request that we've described converge to a unique point: in Azure DevOps, the Pull requests window opens, and you need to fill in the details of your pull request activity. As an example, this is the pull request that we started after the previous commit on the development branch:

Figure 3.55 – New pull request window

Here, you can immediately see that the pull request merges a branch into another branch (in my case, development will be merged into master). You need to provide a title and a description of this pull request (that clearly describes the changes and the implementations you made in the merge), as well as attach links and add team members (users or groups) that will be responsible for reviewing this pull request. You can also include work items (this option will be automatically included if you completed a commit attached to a work item previously).

In the Files section...

Tagging a release

Git Tags are references that point to specific points in the Git history. Tags are used in Azure DevOps for marking a particular release (or branch) with an identifier that will be shared internally in your team to identify, for example, the "version" of your code base.

As an example, in the previous section, we merged the development branch into the master branch by using a pull request. Now, the master branch contains our latest release of the code, which we're now ready to share internally.

To use tags for your branches, in the Repos hub in Azure DevOps, go to the Tags menu:

Figure 3.61 – Tags

From here, you can create a tag for this release by going to Tags and clicking on New Tag.

Here, you're prompted to insert a tag name (an identifier that cannot contain spaces), provide a description for this tag, and select the branch that the tag will be applied to:

Figure 3.62...

Summary

In this chapter, we learned how to handle source control management with Azure DevOps and why it's so important when working in teams when developing code.

We looked at the basic concepts of source control management and Git, the possible strategies to apply when merging code, how to use Azure DevOps to apply SCM, and how to handle repositories, commits, branches, and pull requests from Azure DevOps and development tools such as Visual Studio Code and Visual Studio. We also learned how to apply better policies to control the source code releases in order to improve the SCM life cycle, how to protect branches and how to use tags for a branch.

In the next chapter, we'll learn how to create build pipelines with Azure DevOps for implementing CI/CD practices.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Azure DevOps Explained
Published in: Dec 2020Publisher: PacktISBN-13: 9781800563513
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Sjoukje Zaal

Sjoukje Zaal is head of the Microsoft Cloud Center of Excellence, Microsoft Regional Director, and Microsoft Azure MVP with over 20 years' experience in architecture, development, consultancy, and design-related roles. She currently works at Capgemini, a global leader in consultancy, technology services, and digital transformation. She loves to share her knowledge and is active in the Microsoft community as a co-founder of the user groups Tech Daily Chronicle, Global XR Community, and the Mixed Reality User Group. She is also a board member of Azure Thursdays and Global Azure. Sjoukje is an international speaker and is involved in organizing many events. She has written several books and writes blogs.
Read more about Sjoukje Zaal

author image
Stefano Demiliani

Stefano Demiliani is a Microsoft MVP on Business Applications and Azure, MCT, Microsoft Certified Solution Developer (MCSD), Azure Certified Architect, and an expert in other Microsoft related technologies. His main activity is architecting and developing enterprise solutions based on the entire stack of Microsoft technologies (mainly focused on ERP and serverless applications). He has worked with Packt Publishing on many IT books related to Azure cloud applications and Dynamics 365 Business Central and is a frequent speaker at IT conferences around Europe. In his free time Stefano is also a runner and a cyclist.
Read more about Stefano Demiliani

author image
Amit Malik

Amit Malik is an IT enthusiast and technology evangelist from Delhi, India. He specializes in Virtualization, Cloud, and emerging technology space. He has an intense knowledge in building cloud solutions with Microsoft Windows Azure Pack. Amit holds various industry admired certifications from all major OEM's in Virtualization and Cloud space including MCSE for Private Cloud. Amit has designed and built numerous virtualization and private cloud solutions comprising the product lines of Microsoft, VMware, and Citrix. Apart from these, he can be found working on emerging technologies including VDI, hyper convergence, Software Defined Infrastructure solutions including networking and storage, Containers, Big Data, IoT, and other similar technologies. Amit is interested in building products and doing product management in near future for related technology space. You can always reach Amit on LinkedIn (https://in.linkedin.com/in/amitmalik99)or email (contact2amitmalik@gmail.com)
Read more about Amit Malik