You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从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:

  1. First, install the Azure DevOps CLI if you haven't already (it's part of the Azure CLI suite).
  2. Log in and set your default organization/project:
    az login
    az devops configure --defaults organization=https://dev.azure.com/YourOrgName project=YourProjectName
    
  3. 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 YourRepoName with 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
      
方法3:调用Azure DevOps REST API(适合集成到自定义工具/自动化脚本)

If you need to build this into an application or custom workflow, use the REST API:

  1. 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.
  2. 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.
  3. Example with curl and jq (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.

内容的提问来源于stack exchange,提问作者Ben

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:27:49