简体   繁体   中英

How to add a comment to a git pull request via tfs api

I am working on implementing a script that would (hopefully) help in the following scenario:

Our team is using TFS 2013 where our source code is stored in a number of git repositories.

Our development process is like this:

  • A software developer writes code, commits it and pushes the commits to a feature branch on the tfs git repository.
  • The developer creates a pull request via the tfs webinterface, requesting the feature branch to be pulled into our main branch and inviting team members to review the changes.
  • If/when the changes are approved, the changes are merged into the main branch.

Where the script comes in is that we have some automatic build and test jobs (some runs as build definitions in tfs, some runs outside tfs), and would like to have feedback from these jobs as a part of the pull request so the reviewers get this feedback as well. This is very much inspired by the traditional gerrit/jenkins setup.

Our plan is to use the TFS REST api regarding pull requests: https://www.visualstudio.com/integrate/api/git/pull-requests and do the following:

  • Monitor the tfs server for when new pull requests are created and look for the feature branch name.
  • Locate the relevant verification job in our test systems (hardware smoke tests, static code analysis etc.).
  • Add a "robot reviewer" as a reviewer to the pull request.
  • As robot reviewer, add a comment with a summary of the different test results.
  • Depending on the results, vote approved/disapproved to the pull request.

Based on the documentation of the tfs REST api in the link above, all of this seems to be possible, except for the ability to post a comment in the pull request.

Is there another api for interacting with the pull requests in tfs where it is possible to add a comment to the pull request?

I think Git/Pull-Requests/Threads API Documemntation is what you are searching for
They call "Comments" as "Comment Threads" and in the documentation,
its put as "Threads"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM