Github-Repository-Resource Service Connection Issue
See original GitHub issueHave 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 .yml
s 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:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Also this documentation should be updated accordingly: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories
@TingluoHuang Thanks for the quick response!
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:
I’ve opened a separate issue in the docs repository, will update it.