Azure DevOps · Arazzo Workflow

Azure DevOps Review the Oldest Active Pull Request

Version 1.0.0

List active pull requests, open the oldest, and add a review comment.

1 workflow 1 source API 1 provider
View Spec View on GitHub AgileCI/CDDevOpsProject ManagementVersion ControlArazzoWorkflows

Provider

microsoft-azure-devops

Workflows

review-oldest-active-pull-request
Find the oldest active pull request and add a review comment.
Lists active pull requests, and when at least one exists, gets the first one and posts a review comment thread.
3 steps inputs: accessToken, apiVersion, commentText, repositoryId outputs: pullRequestId, threadId, title
1
listActivePullRequests
pullRequests_list
List active pull requests in the repository, returning the oldest first.
2
getPullRequest
pullRequests_get
Fetch the selected pull request with its commits expanded so the reviewer has full context.
3
addReviewComment
pullRequests_addComment
Post an active comment thread asking for a review on the selected pull request.

Source API Descriptions

Arazzo Workflow Specification

microsoft-azure-devops-pull-request-review-cycle-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Azure DevOps Review the Oldest Active Pull Request
  summary: List active pull requests, open the oldest, and add a review comment.
  description: >-
    Drives a lightweight review-queue pattern over Azure Repos. The workflow
    lists active pull requests in a repository, branches on whether any are open,
    fetches the first (oldest) active pull request with its commits expanded, and
    posts an active comment thread asking for a review. Every step spells out its
    request inline so the flow can be read and executed without opening the
    underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: gitApi
  url: ../openapi/azure-devops-git-api-openapi.yml
  type: openapi
workflows:
- workflowId: review-oldest-active-pull-request
  summary: Find the oldest active pull request and add a review comment.
  description: >-
    Lists active pull requests, and when at least one exists, gets the first one
    and posts a review comment thread.
  inputs:
    type: object
    required:
    - apiVersion
    - repositoryId
    - commentText
    properties:
      apiVersion:
        type: string
        description: Azure DevOps REST API version (e.g. 7.1).
      repositoryId:
        type: string
        description: Repository ID or name to scan for active pull requests.
      commentText:
        type: string
        description: Review comment to post on the selected pull request.
      accessToken:
        type: string
        description: Azure DevOps bearer (OAuth 2.0) access token.
  steps:
  - stepId: listActivePullRequests
    description: >-
      List active pull requests in the repository, returning the oldest first.
    operationId: pullRequests_list
    parameters:
    - name: api-version
      in: query
      value: $inputs.apiVersion
    - name: repositoryId
      in: path
      value: $inputs.repositoryId
    - name: searchCriteria.status
      in: query
      value: active
    - name: $top
      in: query
      value: 1
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      oldestPullRequestId: $response.body#/value/0/pullRequestId
      activeCount: $response.body#/count
    onSuccess:
    - name: hasActive
      type: goto
      stepId: getPullRequest
      criteria:
      - context: $response.body
        condition: $.value.length > 0
        type: jsonpath
    - name: noneActive
      type: end
      criteria:
      - context: $response.body
        condition: $.value.length == 0
        type: jsonpath
  - stepId: getPullRequest
    description: >-
      Fetch the selected pull request with its commits expanded so the reviewer
      has full context.
    operationId: pullRequests_get
    parameters:
    - name: api-version
      in: query
      value: $inputs.apiVersion
    - name: repositoryId
      in: path
      value: $inputs.repositoryId
    - name: pullRequestId
      in: path
      value: $steps.listActivePullRequests.outputs.oldestPullRequestId
    - name: includeCommits
      in: query
      value: true
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      title: $response.body#/title
      sourceRefName: $response.body#/sourceRefName
  - stepId: addReviewComment
    description: >-
      Post an active comment thread asking for a review on the selected pull
      request.
    operationId: pullRequests_addComment
    parameters:
    - name: api-version
      in: query
      value: $inputs.apiVersion
    - name: repositoryId
      in: path
      value: $inputs.repositoryId
    - name: pullRequestId
      in: path
      value: $steps.listActivePullRequests.outputs.oldestPullRequestId
    requestBody:
      contentType: application/json
      payload:
        comments:
        - parentCommentId: 0
          content: $inputs.commentText
          commentType: text
        status: active
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      threadId: $response.body#/id
  outputs:
    pullRequestId: $steps.listActivePullRequests.outputs.oldestPullRequestId
    title: $steps.getPullRequest.outputs.title
    threadId: $steps.addReviewComment.outputs.threadId