如何从VisualStudio.com仓库获取含指定信息的Pull Request列表?
Hey there! Let's break down how you can fetch that full list of Pull Requests with all the details you need (title, creator, PR ID, creation date, status) from your VisualStudio.com (now part of Azure DevOps) repository. Here are a few approaches depending on your workflow:
方法1:通过Azure DevOps Web界面直接查看(适合快速手动查看)
This is the simplest way if you just need to browse or export the list quickly:
- Log into your VisualStudio.com (Azure DevOps) organization and navigate to your target project.
- Go to Repos > Pull requests in the left sidebar.
- If your project has multiple repositories, use the Repository dropdown at the top to select your target repo.
- To show all the fields you need: Click the Columns icon (looks like a table with adjustable columns) in the top-right corner of the PR list. Check the boxes for Title, Creator, PR ID, Creation date, and Status—you can also drag to reorder the columns to your preference.
- Want a local copy? Click the Export to CSV button near the filters, and you'll get a file with all those fields ready to open in Excel or a spreadsheet tool.
方法2:使用Azure DevOps CLI(适合命令行爱好者或脚本化场景)
If you prefer working in the terminal or want to automate this, the Azure DevOps CLI is perfect:
- First, install the Azure DevOps CLI if you haven't already (it's part of the Azure CLI suite).
- Log in and set your default organization/project:
az login az devops configure --defaults organization=https://dev.azure.com/YourOrgName project=YourProjectName - Run this command to pull the PR list with your required fields, formatted as a readable table:
az repos pr list --repository YourRepoName --output table --query "[].{PRID:pullRequestId, Title:title, Creator:createdBy.displayName, CreatedDate:creationDate, Status:status}"- Replace
YourRepoNamewith your actual repository name. - To export directly to a CSV file, just redirect the output:
az repos pr list --repository YourRepoName --output csv --query "[].{PRID:pullRequestId, Title:title, Creator:createdBy.displayName, CreatedDate:creationDate, Status:status}" > pr_list.csv
- Replace
方法3:调用Azure DevOps REST API(适合集成到自定义工具/自动化脚本)
If you need to build this into an application or custom workflow, use the REST API:
- Generate a Personal Access Token (PAT) in your Azure DevOps organization: Go to User Settings > Personal Access Tokens, create a token with the Code (Read) permission.
- Send a GET request to the following endpoint (replace placeholders with your org/project/repo details):
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=7.1-preview.1- You can find your repository ID by going to Repos > Manage repositories in your project.
- Example with
curlandjq(to parse and format the JSON response):curl -u :YourPATToken "https://dev.azure.com/YourOrg/YourProject/_apis/git/repositories/YourRepoId/pullrequests?api-version=7.1-preview.1" | jq '[.value[] | {PRID:.pullRequestId, Title:.title, Creator:.createdBy.displayName, CreatedDate:.creationDate, Status:.status}]'- If you don't have
jq, you can parse the JSON response directly in your code (Python, JavaScript, etc.) to extract the required fields.
- If you don't have
内容的提问来源于stack exchange,提问作者Ben
相关产品推荐
相关产品推荐

