image
Integrating GitHub Repositories with Azure Pipelines
Integrating GitHub Repositories with Azure Pipelines
Difficulty
Beginner
Duration
32m
Students
316
Ratings
4.5/5
Description

Source control repositories are an important part of software development. They ensure that data can always be recovered and they also enable continuous integration. Azure DevOps includes features common to modern software development such as source control repositories, continuous integration pipelines, agile planning tools, and more. This course covers several topics which fall under the umbrella of configuring repositories for Azure DevOps.

Learning Objectives

  • Integrating GitHub repositories with Azure DevOps Pipelines
  • Configuring permissions in source control repositories
  • Configuring tags to organize source control repositories 
  • Recovering data using Git commands
  • Purging data from source control

Intended Audience

  • Software engineers
  • DevOps engineers
  • Site reliability engineers

Prerequisites 

  • Be comfortable using Git
  • Be familiar with Azure DevOps
Transcript

Hello and welcome. In this content, we'll explore how to integrate GitHub repositories into Azure DevOps Pipelines. GitHub is one of the most popular social coding platforms. It's widely used by individuals, teams, and organizations to manage software development projects. Integrating GitHub repositories into DevOps pipelines enables continuous integration. Azure DevOps provides a relatively simple workflow for integrating GitHub repositories into pipelines. 

The general flow is as follows: It starts by opening an Azure DevOps project, followed by creating a pipeline, selecting GitHub as the repository source, authorizing Azure DevOps to access the GitHub account, selecting the repository to integrate, defining the pipeline, and finally saving and running the pipeline. Azure DevOps automatically runs pipelines in response to code changes in the GitHub repository. Let's see how to integrate GitHub repositories in action.

I'm currently logged into Azure DevOps. I have an existing project here named az-400. Clicking the project card opens up the project. On the left-hand side navigation, I'll click on the Pipelines button. Currently, no pipelines exist, so I'll click the Create Pipeline button. And the first step is to select the repository location. I'm going to select the GitHub option. Azure redirects us to the GitHub (OAuth) based authorization page. Azure requires access to the GitHub account. 

I'm currently logged into GitHub with my personal credentials. This is the account I'll use in this demo. It's worth noting that, in a production environment, using a personal account is not recommended. It's best to use an account specifically created for build automation. The account credentials should be centrally managed and accessible to more than one developer. I'm going to click on the Authorize button and be redirected back to Azure DevOps.

The next step is to select the repository to integrate into the pipeline. I'm going to use a private repository containing a Flask-based web application. The next step is to configure the pipeline. Azure includes several preconfigured pipeline templates. Pipelines are defined as YAML files. I'm going to select the Python package template. This template attempts to install application dependencies and run unit tests using different versions of the Python runtime. 

I'm going to paste in a template that I've created outside of this content. This is a slightly different version of the previous template that performs the same basic task. Dependencies are installed and unit tests are run. With this complete, the next step is to save and run the pipeline. For that I'll click the Save and run button. Notice this sidebar asks for a commit message. Azure DevOps is going to add the YAML-based pipeline file to the repository. By default, the main branch is used. However, an alternate branch can be used and a pull request can be created.

I'll use the main branch for this. The build job is now queued up and it will run shortly. Notice the job changes from a status of queued to running. Clicking on the job displays the output of the scripts used in the pipeline. After each job is run, another starts up. The green check mark indicates that the job ran successfully. Output from the jobs is available as raw text with timestamps. This is useful for debugging failed builds. 

If I switch over to GitHub, we can see that the azure-pipelines.yml file was added. Azure added this file for us upon saving and running. However, if this file was already in the repository, Azure DevOps would pick it up and use it rather than presenting us with the option to select a template. With this configured, Azure DevOps will automatically run when the repository is changed. And with that, we're going to wrap up here. I hope this demonstration has been helpful. Thanks for watching.

 

About the Author
Students
101042
Labs
37
Courses
44
Learning Paths
58

Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.