Visual Studio Online - Pull Request Bot

Jonathan Ruckert's Avatar

Jonathan Ruckert

09 Sep, 2017 02:16 AM

Hi,

As VSTS rooms are being deprecated, I'm trying to integrate a build condition from AppVeyor in Visual Studio Online in a very similar way to how you have made it available for GitHub (https://www.appveyor.com/docs/notifications/#github-pull-request) but i'm stuck on storing the "refresh auth token" and making it work across multiple projects, so i'm wondering if this would be a viable feature as you already have authentication flow working with VSTS?

Specifically i'm keen on configuring this part of the branch policy within VSTS

** Require approval from external services
** Require third party services to post successful status to complete pull requests.

https://www.visualstudio.com/en-us/docs/integrate/get-started/authentication/oauth
https://www.visualstudio.com/en-us/docs/integrate/api/git/pull-requests/pullrequeststatuses#create-pull-request-iteration-status

At this stage, I can hook up some Powershell which performs the following actions

1. Setup Authorisation Token
2. Call Pull Request API with current status of build

on the the following events in the appveyor YML

before_build - set state = pending
on_success - set state = succeeded
on_failure - set state = failed

This posts a message to (after I get around my authorisation issue by creating a new auth token manually each time and putting it in the build)

POST https://mytenant.visualstudio.com/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/iterations/{iterationId}/statuses?api-version={version}

BODY
     {
         "state": "succeeded",
         "description": "Build succeeded",
         "context": {
           "name": "ci-status-success",
           "genre": "appveyor"
         },
         "targetUrl": "http://ci.appveyor/project/myaccount/data-validation/build/1.0.51"
       }

where the status and is configured using

https://www.visualstudio.com/en-us/docs/integrate/api/git/pull-requests/pullrequeststatuses#GitPullRequestStatus

but i'm then stuck on storing the auth token to be re-used after the build finishes, but everything else works great and I can stop a PR if the build fails.

Is this something that can be implemented please, I hope that I've given enough information to make this relatively easy as it is currently working as a Proof of Concept for me by using straight Powershell and existing VSTS API's.

Cheers,
Jonathan

  1. 1 Posted by Ilya Finkelshte... on 12 Sep, 2017 06:28 PM

    Ilya Finkelshteyn's Avatar

    Hi Jonathan,

    Sorry for delay. We created this issue on GitHub and internally it has high priority.

    I put link to this discussion to that GitHub issue. Please make it public, If you feel comfortable with it, so other people could add their opinion. If not, that's totally fine :)

    Ilya.

  2. 2 Posted by Jonathan Rucker... on 12 Sep, 2017 09:40 PM

    Jonathan Ruckert's Avatar

    Thank you!

  3. 3 Posted by Jonathan Rucker... on 22 Dec, 2017 12:56 AM

    Jonathan Ruckert's Avatar

    Hi Ilya, just wondering if this is still planned for a future release, and when you think it would be implemented?

  4. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:25 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM
20 Sep, 2024 05:50 PM