Mastering Azure DevOps URLs and Git Repositories

Author

Reads 689

Blurred Blue Design
Credit: pexels.com, Blurred Blue Design

Azure DevOps URLs are a crucial part of any software development project, providing a centralized location for storing and managing code.

A default Azure DevOps URL is in the format https://dev.azure.com/{organization}/ where {organization} is the name of your Azure DevOps organization.

Azure DevOps URLs can be customized to include a unique subdomain, making it easier to identify your organization's projects.

Azure DevOps URLs

Azure DevOps URLs are used to identify and access your projects, repositories, and collections. You can access your project's clone URL in the Files view of your Azure DevOps project.

To get the clone URL of an Azure Repos Git repo, follow these steps:

  1. From your web browser, open the team project for your Azure DevOps organization, and then choose Repos > Files to open the Files view.
  2. In the Files view, choose Clone to launch the Clone Repository popup.
  3. Copy the clone URL from the Clone Repository popup.

The format for the project URL is dev.azure.com/{your organization}/{your project}, but the previous format that references the visualstudio.com format is still supported.

Server

Azure DevOps URLs can be a bit tricky to navigate, but don't worry, I've got you covered.

For Azure DevOps Services, the server URL is simply https://dev.azure.com/{your-organization}.

If you're working with Azure DevOps Server, your server URL will be https://{my-server}/{my-collection}.

Pull Requests

Credit: youtube.com, Azure devops Repos New repo, commits, pull requests

Pull requests are a crucial part of the Azure DevOps workflow, allowing developers to collaborate and review code changes before merging them into the main branch.

You can create a pull request from the Pull requests page on the web, by selecting New pull request at the upper right, and then choosing the branch with the changes and the branch you want to merge the changes into.

To create a pull request from a pushed branch, you can use the az repos pr create command, or right-click the branch name and select Create Pull Request in the Branches view in Team Explorer.

Pull requests can also be created from a linked work item in Azure Boards, by opening a work item that's linked to the branch, and then selecting Create a pull request.

You can edit the title and description of a pull request at any time, either by selecting the current title and updating the text, or by using the az repos pr update command with the --title and --description parameters.

To add reviewers to a pull request, you can search for users and groups to add as reviewers, and then select their names to add them as optional or required reviewers. You can also use the az repos pr reviewer command to add, list, or remove reviewers.

PR from the Page

Credit: youtube.com, How to Review a Pull Request in GitHub the RIGHT Way

You can create a PR from the Pull requests page on the web. To do this, select New pull request at the upper right of the Repos > Pull requests page.

Select the branch with the changes and the branch you want to merge the changes into, such as the main branch. This is a crucial step in creating a PR that will merge your changes into the main codebase.

Enter your PR details and create the PR. This is where you'll add a title, description, and any other relevant information about your changes.

Here's a quick rundown of the steps:

  1. On the Repos > Pull requests page, select New pull request at upper right.
  2. Select the branch with the changes and the branch you want to merge the changes into.
  3. Enter your PR details and create the PR.

Draft PRs

Draft PRs are a great way to indicate work in progress and get feedback before making a PR public. To create a draft PR, select the arrow next to Create and choose Create as draft when creating the PR.

You don't have to use title prefixes like WIP or DO NOT MERGE. Creating draft PRs requires Azure DevOps Server 2019.1 update or later version.

Credit: youtube.com, About DRAFT Pull Requests

Draft PRs have some differences from published PRs. Here are the key differences:

  • Build validation policies don't run automatically.
  • Voting is disabled while in draft mode.
  • Required reviewers aren't automatically added.
  • Draft PRs display in the PR list with a Draft badge.

To change an existing published PR to a draft, choose Mark as draft. Marking a PR as draft removes all existing votes.

Edit PR Title and Description

Editing a pull request (PR) title and description is a crucial step in keeping your reviewers informed about the changes you're proposing. You can update the title of an existing PR by selecting the current title and updating the text.

To edit the title, description, or any other details in an existing PR, you can open the PR in your browser. You can also use the command line to update details in existing PRs with `az repos pr update`.

You can add details during PR creation with `az repos pr create`, or update details in existing PRs with `az repos pr update`. The `--description` parameter accepts Markdown entry, and each value in the argument is a new line of the PR description.

Credit: youtube.com, How to update Github pull request

To update the title and description for a PR, use `az repos pr update` with the required `--id` parameter. For example, to update the title and description for PR #21, use: `az repos pr update --id 21 --title new title --description new description`.

You can update the title and description of a PR at any time, and it's a good idea to keep these fields up to date so reviewers can understand the changes in the PR.

Repository Management

Repository management in Azure DevOps is a breeze. You can import a new repository by selecting Repos, Files and then clicking on Import repository from the repo drop-down.

To import a public repository, simply enter the clone URL of the source repository and a name for your new Git repository. If the source repository is private, you'll need to select Requires authorization and enter your credentials.

You can also manually import a repository that uses SSH authentication by following the steps in Manually import a repo using git CLI, but SSH authentication is not supported directly.

Here are the steps to import a private repository:

  1. Select Repos, Files.
  2. From the repo drop-down, select Import repository.
  3. Enter your credentials if the source repository is private.

Get Git Repo Clone URL

Credit: youtube.com, How to clone GitHub repository ?

If you need to get the clone URL of an Azure Repos Git repo, you can follow these steps.

First, sign into your Azure DevOps project. Visual Studio will support searching for and cloning project repos without needing to know the clone URL.

To get the clone URL, open the team project for your Azure DevOps organization and then choose Repos > Files to open the Files view.

Next, choose Clone to launch the Clone Repository popup, and then copy the clone URL from the popup.

The format for the project URL is dev.azure.com/{your organization}/{your project}, but the previous format that references the visualstudio.com format is still supported.

Add Tags

Adding tags to a pull request can help communicate important details to reviewers. You can type a tag name in the Tags section when creating a PR. To add tags after creating a PR, manage them in the Tags section.

Tags can show that a PR is still a work in progress or is a hotfix for an upcoming release. This extra information can help reviewers understand the context of the PR.

Switch Branches

Credit: youtube.com, Git Branches Tutorial

Switching branches is a crucial part of managing your repository, and fortunately, it's easier than you think.

Before you save a pull request, you can switch the source and target branches by selecting the Switch source and target branches icon next to the branch names. This can be a lifesaver if you've made a mistake or need to change plans.

If you've already saved a pull request and need to change the target branch, don't worry – it's still possible. You can do this by selecting More actions at the upper-right corner of the PR Overview page and then choosing Change target branch from the dropdown menu.

To change the target branch, simply select Choose a target branch, pick the new branch, and then select Change. It's that simple!

In some cases, you might need to change the target branch of an active pull request. Here's a step-by-step guide to help you do just that:

  1. Select More actions at upper-right on the PR Overview page, and then select Change target branch from the dropdown menu.
  2. In the Change target branch pane, select Choose a target branch, select the new branch, and then select Change.

Source Repository Behind 2FA

Credit: youtube.com, How to enforce Organization wide 2FA in GitHub

If your source repository is behind two-factor authentication, you're in luck because most Git hosting providers support personal tokens.

These personal tokens can be supplied to the import service, allowing it to work with repositories that require two-factor authentication.

The import service uses REST APIs to validate and trigger import, but it can't work directly with repositories that need two-factor authentication.

This is a common solution used by popular Git hosting providers like GitHub and Azure DevOps Services.

By using personal tokens, you can safely import your repository without compromising your two-factor authentication security.

Importing and Updating

Importing and updating repositories in Azure DevOps is a straightforward process. You can import a repository from another Git repository using the Import repository feature.

To import a repository, select Repos, Files and then Import repository from the repo drop-down. If the source repository is publicly available, you can simply enter the clone URL and a name for your new Git repository. However, if the source repository is private, you'll need to select Requires authorization and enter your credentials.

Credit: youtube.com, #azuredevopssprints 159 - Import work items from a CSV file

You can also use the az repos CLI to import a repository. This method is useful if you want to automate the import process or if you're working with large repositories. To use the az repos CLI, you'll need to create the repository in Azure DevOps first and make sure it's empty.

Here are the parameters you'll need to specify when using the az repos CLI:

If you need to import changes from a source repository that has changed later, you'll need to use a local clone of the repository with remotes set to both source and destination. You can sync changes using the following commands: "We'll treat the Azure Repos import as origin and the original repo as upstream."

Notifications and Settings

You can share a pull request by email to notify reviewers and communicate with team members. To share a PR, select More options on the PR Overview page, and then select Share pull request.

Credit: youtube.com, 17-Configure notifications in Azure DevOps

The email feature only sends emails to project members' individual addresses, and adding a team group or security group to the To: line isn't supported. If you add an email account that the system doesn't recognize, you receive a message that one or more recipients of your email don't have permissions to read the mailed pull request.

For the email feature to work, your administrator for Azure DevOps Server must configure an SMTP server, which is a requirement for sending emails.

Add Attachments

You can attach files, including images, to your pull requests during or after creation.

To do this, select the paper clip icon below the Description field, or drag and drop files directly into the Description field of the PR.

This is a convenient way to add context to your pull requests and make them more informative for reviewers.

Email Notifications

Email notifications can be a powerful tool for keeping your team informed about pull requests. You can share a pull request by email to notify reviewers and communicate with team members.

Credit: youtube.com, How To Add Email Notifications To A SharePoint List

To share a pull request, select More options on the PR Overview page and then select Share pull request. This will open the Share pull request screen, where you can add recipients by typing their names in the To: field and selecting from the user names that appear.

You can also remove recipients from the email if needed. Adding an optional message in the Note (Optional) field is a good idea, especially if you want to provide context about the pull request.

Recipients receive an email requesting their attention and linking to the PR. If you use the built-in email feature, you can only send the email to project members' individual addresses.

Adding a team group or security group to the To: line isn't supported. If you add an email account that the system doesn't recognize, you receive a message that one or more recipients of your email don't have permissions to read the mailed pull request.

To ensure the email feature works, your administrator for Azure DevOps Server must configure an SMTP server.

Parameters and Options

Credit: youtube.com, Pass variables and parameters between build and release pipelines on Azure DevOps

When creating a pull request in Azure DevOps, you have several parameters and options to customize the process. You can set the pull request to complete automatically and merge into the target branch when all policies pass by using the `--auto-complete` parameter.

The `--bypass-policy` parameter allows you to bypass any required policies and complete the pull request once it's mergeable, with accepted values of `false` or `true`. You can also specify a reason for bypassing required policies using the `--bypass-policy-reason` parameter.

You can configure the default organization and project using `az devops configure`, and specify the repository, source branch, and target branch using the `--repository`, `--source-branch`, and `--target-branch` parameters, respectively. The `--repository` parameter is a required parameter.

Here's a summary of some key parameters:

Use Templates

Using templates can save you time and ensure consistency across your project. A default pull request template can be created to add text to all new PR descriptions in the repo.

Credit: youtube.com, ARM Templates Parametrization | Expressions, Parameters and Variables

You can also select from branch-specific templates or other templates your team defines. This is especially helpful when working on complex projects with multiple branches.

To add a template, select Add a template and then choose a template from the dropdown list. This can be done in addition to the default template.

Templates can be edited, removed, or combined with other text in the PR description. This flexibility allows you to tailor the template to your team's specific needs.

Parameters

The Parameters section is where things get really interesting. You can use the `--auto-complete` parameter to set the pull request to complete automatically and merge into the target branch when all policies pass.

There are two accepted values for this parameter: `false` and `true`. It's worth noting that I've seen this parameter come in handy when working on projects with multiple team members.

You can also use the `--bypass-policy` parameter to bypass any required policies and complete the pull request once it's mergeable. This parameter also has two accepted values: `false` and `true`.

Credit: youtube.com, Jenkins Beginner Tutorial - Tips 4 💡 How to create Parameters - CHECK BOX, DROP DOWN, RADIO BUTTON

The `--bypass-policy-reason` parameter is used to specify the reason for bypassing required policies. This is an important one to get right, as it can impact the overall integrity of the project.

The `--delete-source-branch` parameter allows you to delete the source branch after the pull request is completed and merged into the target branch. Again, this has two accepted values: `false` and `true`.

Here's a summary of the parameters we've covered so far:

The `--description` parameter is used to specify a description for the new pull request, which can include Markdown. Each value is a new line, so you can use this parameter to add multiple lines of description.

Thomas Goodwin

Lead Writer

Thomas Goodwin is a seasoned writer with a passion for exploring the intersection of technology and business. With a keen eye for detail and a knack for simplifying complex concepts, he has established himself as a trusted voice in the tech industry. Thomas's writing portfolio spans a range of topics, including Azure Virtual Desktop and Cloud Computing Costs.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.