question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Github-Repository-Resource Service Connection Issue

See original GitHub issue

Have you tried trouble shooting?

Yes

VSTS Type and Version

VisualStudio.com

Account Name

http://jeremytcd.visualstudio.com

What’s not working?

I’m having a service connection issue when attempting to use a Github repository as a resource. I am aware of the advisory Troubleshoot Azure Resource Manager service connections and I’ve read through all of the information on repository resources and service connections I could find (article 1, article 2, article 3). I could not resolve my issue, so I created reproduction repositories:

IssueReproduction.RepositoryResource.Template

This repository has a single file, template.yml, with the following contents:

jobs:
- job: Test
  pool:
    vmImage: 'vs2017-win2016'
  steps:
  - script: echo success

IssueReproduction.RepositoryResource.Consumer

This repository has a single file, consumer.yml, with the following contents:

resources:
  repositories:
  - repository: templates
    type: github
    name: JeremyTCD/IssueReproduction.RepositoryResource.Template
    endpoint: https://github.com/JeremyTCD/IssueReproduction.RepositoryResource.Template.git

jobs:
- template: template.yml@templates

It adds the template repository as a resource using the method documented here and uses template.yml.

Pipeline

After creating those repositories, I created a pipline - IssueReproduction.RepositoryResource.Consumer-CI.

Note, initially, consumer.yml had no endpoint option, as per the documentation. Without it, I got these errors:

Repository templates requires an endpoint

Parameter name: endpoint,Unable to cast object of type 'Microsoft.TeamFoundation.DistributedTask.Pipelines.Yaml.Templates.JobsTemplateReference' to type 'Microsoft.TeamFoundation.DistributedTask.Pipelines.Yaml.Templates.Job'.

The documentation might need updating with regard to endpoint being required.

With the endpoint, I get these errors:

Repository templates references endpoint https://github.com/JeremyTCD/IssueReproduction.RepositoryResource.Template.git which does not exist or is not authorized for use

Unable to cast object of type 'Microsoft.TeamFoundation.DistributedTask.Pipelines.Yaml.Templates.JobsTemplateReference' to type 'Microsoft.TeamFoundation.DistributedTask.Pipelines.Yaml.Templates.Job'.

Here is an example build result: result.

What I’ve tried

I noticed that tasks accept service connection options, like azureSubscription. The documentation does not specify any equivalent for repositories. I tried random stuff like githubSubscription but nothing worked.

Some Github issues, such as this one suggested stuff like adding variables and switching branches. These seem to apply more for when .ymls are changed after their initial loading. I tried them anyway and nothing worked.

I’ve checked my pipeline’s service connections. Since the root repository is also on Github, Get Sources already has a valid service connection to Github. I’m not sure if this connection is used for all jobs. Regardless, I could not find any way to add a service connection “for the entire pipline”.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
martinm82commented, Mar 14, 2019
2reactions
JeremyTCDcommented, Oct 23, 2018

@TingluoHuang Thanks for the quick response!

https://github.com/Microsoft/azure-pipelines-yaml is the new repository for all yaml related question moving forward.

Okay, would be helpful if this was noted in the ReadMe for this repository.

The fix worked, though the documentation here needs to be fixed:

resources:
  repositories:
  - repository: string  # identifier (no spaces allowed)
    type: enum  # see below
    name: string  # repository name (format depends on `type`)
    ref: string  # ref name to use, defaults to 'refs/heads/master'
    endpoint: string  # endpoint for a GitHub repository

I’ve opened a separate issue in the docs repository, will update it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Use Existing Service Connection · Issue #881
--service-connection : Id of the Service connection created for the repository for GitHub repository. Use command az devops service-endpoint -h ...
Read more >
Github service connection not updating with Azure Devops
I have a service connection setup to github so that my pipeline can access the repositories that the project references.
Read more >
Unable to find GitHub service connection in Download ...
Type: Question Task: Download GitHub Release Environment Server - Azure Pipelines - Account name: dev.azure.com/avaisuddinmohammad - Project ...
Read more >
Service connections in Azure Pipelines
The Azure Resource Manager service connection is a single example of a service connection ... Select Project settings > Service connections.
Read more >
GitHub Service connections using the GitHub App "Azure ...
In a Release Pipeline, if I enable a Continuous deployment trigger on a build that uses the extension service connection, it doesn't work,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found