Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving build definition is giving error in Visual Studio Team Service

I have started build automation using vs team service. I have linked my github repositories with Visual Studio Team Services through personal access token.

Now I am able to select github repositories in Visual Studio Team Services. But while saving build definitions it is giving following error:

Unable to configure a service on the selected GitHub repository. This is likely caused by not having the necessary permission to manage hooks for the selected repository.

Can anyone please help me how to resolve this error. Do we need to buy any service for build automation?

Thanks in advance.

like image 465
sandy Avatar asked Mar 22 '16 06:03

sandy


2 Answers

There's another situation that also provokes this issue, specifically related to configuring the Continuous Integration trigger.

I have a github account with my own repos, but I'm also a collaborator on a different project (which is a personnel not an organization repo).

GH allows me to create a personal access token and VSO considers it valid for use when configuring the Repository options on the build definition but it does not have the appropriate rights to create a Continuous Integration trigger acting as collaborator to the other private repo.

The reason is that triggering notification is performed using GitHub Web Hooks. It appears that when first creating the CI trigger, VSO initiates a request into the GH API to subscribe to the push event for the requested repo ... except that the personal access token includes the admin:repo_hook right for your own repo(s), not any for which you are a collaborator as this right cannot be delegated for a personal account.

It took me a bit of experimentation to figure this out. 8-}

Within this context, I think there are two possible solutions:

  1. Ask the repo owner to generate and provide you his personal access token with an appropriately narrow scope of rights;
  2. Transfer ownership of the repo to an organization, be granted appropriate rights as a member of that organization, and then create your VSO endpoint using your GH user credentials instead of a PAT.

HTH.

like image 184
Sam C Avatar answered Sep 20 '22 19:09

Sam C


You can only build the github repositories hosted in VS Team Service which you are authorized to push to.

Two ways:

Connect using your GitHub user account

  1. On the Repository tab, next to the Connection drop-down, click the Manage link. The Services tab opens as a new tab in your browser.

    a.Click New Service Endpoint and choose GitHub.

    b.In the Add New GitHub Service Connection dialog box, select Grant authorization, and then click Authorize.

    c.In the new browser window, sign in to GitHub and follow the instructions to authorize Visual Studio Team Services to access your GitHub account.

  2. On the Repository tab, select the Connection you created.

  3. Select the Repository that contains the code you want to build.

Connect using a personal access token

  1. Sign in to GitHub and make sure you have permission to read the repository.
  2. In GitHub, create an access token.

    a.Select the repo, user, and admin:repo_hook scopes.

    b.Copy the token to your clipboard.

  3. Sign on to Team Services and create a build definition.

  4. On the Repository tab, next to the Connection drop-down, click the Manage link. The Services tab opens as a new tab in your browser.

    a.Click New Service Endpoint and choose GitHub.

    b.In the Add New GitHub Service Connection dialog box, select Personal access token.

    c.Paste the token and give the connection a name.

  5. On the Repository tab, select the Connection you created.

  6. Select the Repository that contains the code you want to build.

More details you can refer the link from MSDN: Specify the repository - GitHub

like image 39
PatrickLu-MSFT Avatar answered Sep 19 '22 19:09

PatrickLu-MSFT