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. Support Staff 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?

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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

Recent Discussions

18 Aug, 2018 12:13 AM
17 Aug, 2018 09:45 PM
17 Aug, 2018 06:02 PM
17 Aug, 2018 04:26 PM
17 Aug, 2018 04:04 PM