- Azure DevOps Server 2019 Cookbook(Second Edition)
- Tarun Arora Utkarsh Shigihalli
- 484字
- 2021-06-24 14:18:38
Getting ready
Let's cover the principles of what is being proposed:
- The master branch:
- The master branch is the only way to release anything to production.
- The master branch should always be in a ready-to-release state.
- Protect the master branch with branch policies.
- Any changes to the master branch flow through pull requests only.
- Tag all releases in the master branch with Git tags.
- The feature branch:
- Use feature branches for all new features and bug fixes.
- Use feature flags to manage long-running feature branches.
- Changes from feature branches to the master only flow through pull requests.
- Name your feature to reflect their purpose, like so:
List of branches:
features/feature-area/feature-name
users/username/description
users/username/workitem
bugfix/description
features/feature-name
features/feature-area/feature-name
hotfix/description
- Pull requests:
- Review and merge code with pull requests.
- Automate what you inspect and validate as part of pull requests.
- Track pull request completion duration and set goals to reduce the time it takes.
In this recipe, we'll be using the myWebApp we created in the Pull Request for code review using branch policies recipe. If you haven't already, follow that recipe to lock down the master branch using branch policies. In this recipe, we'll also be using two very popular extensions from the marketplace:
- The VSTS CLI (https://marketplace.visualstudio.com/items?itemName=ms-vsts.cli): This is a new command-line experience for Azure DevOps (AzDo) and Azure DevOps Server (AzDos), and was designed to seamlessly integrate with Git, CI pipelines, and Agile tools. With the VSTS CLI, you can contribute to your projects without ever leaving the command line. VSTS CLI runs on Windows, Linux, and Mac.
- Git Pull Request Merge Conflict (https://marketplace.visualstudio.com/items?itemName=ms-devlabs.conflicts-tab): This open source extension that was created by Microsoft DevLabs allows you to review and resolve pull request merge conflicts on the web. Before a Git pull request can complete, any conflicts with the target branch must be resolved. With this extension, you can resolve these conflicts on the web, as part of the pull request merge, instead of performing the merge and resolving conflicts in a local clone.
In order to use the VSTS-CLI, you'll need to log in with your PAT token. To make full use of the VSTS CLI, you should check the All scopes option when generating the PAT. Since the URL of the Azure DevOps Server instance needs to be used in most commands, it's best to store it as a variable and reference it when required. You can get a list of all the Git repositories in the parts unlimited team project:
$Azure DevOps Server = "https://Azure DevOps Server2018.westeurope.cloudapp.azure.com/Azure DevOps Server"
vsts login --token xxxxxxx --instance $Azure DevOps Server
$prj = "PartsUnlimited"
vsts code repo list --instance $i --project $prj --output table