Azure DevOps · Arazzo Workflow

Azure DevOps Open a Pull Request and Start a Review Thread

Version 1.0.0

Create a pull request, confirm it, and add an opening review comment thread.

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

Provider

microsoft-azure-devops

Workflows

open-pull-request-and-comment
Create a pull request, confirm it, and add an opening comment thread.
Creates a pull request, retrieves it to confirm creation, and adds an active comment thread to start the review.
3 steps inputs: accessToken, apiVersion, commentText, description, repositoryId, sourceRefName, targetRefName, title outputs: lastMergeSourceCommitId, pullRequestId, threadId
1
createPullRequest
pullRequests_create
Create the pull request between the supplied source and target branches.
2
confirmPullRequest
pullRequests_get
Fetch the pull request to confirm it is active and capture the head commit of the source branch for later completion.
3
addReviewThread
pullRequests_addComment
Post an active comment thread on the pull request to start the review.

Source API Descriptions

Arazzo Workflow Specification

microsoft-azure-devops-pull-request-create-comment-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Azure DevOps Open a Pull Request and Start a Review Thread
  summary: Create a pull request, confirm it, and add an opening review comment thread.
  description: >-
    Opens a pull request from a source branch into a target branch and kicks off
    the review conversation. The workflow creates the pull request, fetches it to
    confirm its active status and capture the head commit of the source branch,
    and then adds an active comment thread asking reviewers to begin. 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: open-pull-request-and-comment
  summary: Create a pull request, confirm it, and add an opening comment thread.
  description: >-
    Creates a pull request, retrieves it to confirm creation, and adds an active
    comment thread to start the review.
  inputs:
    type: object
    required:
    - apiVersion
    - repositoryId
    - title
    - sourceRefName
    - targetRefName
    - commentText
    properties:
      apiVersion:
        type: string
        description: Azure DevOps REST API version (e.g. 7.1).
      repositoryId:
        type: string
        description: Repository ID or name to open the pull request in.
      title:
        type: string
        description: Title for the pull request.
      description:
        type: string
        description: Optional description for the pull request.
      sourceRefName:
        type: string
        description: Source branch ref (e.g. refs/heads/feature/login).
      targetRefName:
        type: string
        description: Target branch ref (e.g. refs/heads/main).
      commentText:
        type: string
        description: Opening review comment to post on the pull request.
      accessToken:
        type: string
        description: Azure DevOps bearer (OAuth 2.0) access token.
  steps:
  - stepId: createPullRequest
    description: >-
      Create the pull request between the supplied source and target branches.
    operationId: pullRequests_create
    parameters:
    - name: api-version
      in: query
      value: $inputs.apiVersion
    - name: repositoryId
      in: path
      value: $inputs.repositoryId
    requestBody:
      contentType: application/json
      payload:
        title: $inputs.title
        description: $inputs.description
        sourceRefName: $inputs.sourceRefName
        targetRefName: $inputs.targetRefName
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      pullRequestId: $response.body#/pullRequestId
      status: $response.body#/status
  - stepId: confirmPullRequest
    description: >-
      Fetch the pull request to confirm it is active and capture the head commit
      of the source branch for later completion.
    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.createPullRequest.outputs.pullRequestId
    successCriteria:
    - condition: $statusCode == 200
    - condition: $response.body#/status == active
    outputs:
      lastMergeSourceCommitId: $response.body#/lastMergeSourceCommit/commitId
      mergeStatus: $response.body#/mergeStatus
  - stepId: addReviewThread
    description: >-
      Post an active comment thread on the pull request to start the review.
    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.createPullRequest.outputs.pullRequestId
    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.createPullRequest.outputs.pullRequestId
    lastMergeSourceCommitId: $steps.confirmPullRequest.outputs.lastMergeSourceCommitId
    threadId: $steps.addReviewThread.outputs.threadId