Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference YAML template from another VSTS project #1633

Closed
wsmckenz opened this issue Jun 19, 2018 · 19 comments
Closed

Reference YAML template from another VSTS project #1633

wsmckenz opened this issue Jun 19, 2018 · 19 comments
Assignees
Labels

Comments

@wsmckenz
Copy link

Have you tried trouble shooting?

Trouble shooting doc

Agent Version and Platform

2.115

OS of the machine running the agent? Linux

VSTS Type and Version

VisualStudio.com

If VisualStudio.com, what is your account name? http://chevron.visualstudio.com

What's not working?

  1. Repository resources. Do you have plans to allow a reference to a repository in another project? This is super critical for us. We have several hundred projects, and would like share common build phases across them. The syntax of Project/Repo in the name field would be ideal.

  2. Library Variable Groups. Any plans to make those available as a resource in the yaml? This would greatly reduce the number of manual steps required to modify the build after pushing the initial .vsts-ci.yml. Again, cross-project would be nice, but really not as critical as sharing build steps across projects.

Agent and Worker's Diagnostic Logs

n/a

@ericsciple
Copy link
Contributor

@patrickcarnahan is variable-group-support within the yaml file rolling out with the current deployment?

@patrickcarnahan
Copy link
Contributor

patrickcarnahan commented Jun 20, 2018

Yes this is rolling out with our current sprint, allowing variables/variable groups both at the root level and at the phase level. The variables are an ordered list and will be applied in the order defined within the file.

@wsmckenz once this reaches the scale unit where your account is hosted would you like for us to enable the feature for you so you can take advantage and provide early feedback? Given where your account is located (one of our last rings for deployment) it may take up to a week or more before the variable group changes reach your account.

@wsmckenz
Copy link
Author

Excellent news, and yes, absolutely would like to do that.

Who do I have to bribe to get ussc up into an earlier ring?

@wsmckenz
Copy link
Author

So, what about request #1? Are cross-project repository resources on the road map at all? Just trying to figure out if it is coming at some point, or really hard to do for some reason?

@patrickcarnahan
Copy link
Contributor

@wsmckenz it's not that it is hard to do we just haven't implemented it yet. I will see if I can fit it in to our current sprint, which would roll out in approximately 3 weeks. If it turns out to be low risk and simple I can certainly looking at back-porting to our current rollout. I will let you know once I know more.

@wsmckenz
Copy link
Author

Excellent, thanks for the response. Love what you guys are doing with these features.

@camillemahaut
Copy link

Hello everyone, any update about this issue ?
Really interesting to have Variable Groups available as a resource in the yaml.

@ericsciple ericsciple self-assigned this Aug 10, 2018
@ericsciple ericsciple changed the title Feature Request - Pull resources from another project. Reference YAML template from another VSTS project Aug 10, 2018
@ericsciple
Copy link
Contributor

Sorry for the delay @wsmckenz we haven't forgotten about this. It's on the backlog, and we just haven't gotten to it yet.

@ericsciple
Copy link
Contributor

@camillemahaut variable groups has rolled out everywhere I believe, I don't think we have docs for this yet. Here is the syntax:

variables:
- name: var1  # this is a regular variable named var1
  value: val1
- group: group1  # this is a reference to a variable group named group1

@patrickcarnahan @vtbassmatt fyi do we have docs for this in a user branch or anywhere?

@timwebster9
Copy link

I'm interested in this bit as well:

Repository resources. Do you have plans to allow a reference to a repository in another project? This is super critical for us. We have several hundred projects, and would like share common build phases across them. The syntax of Project/Repo in the name field would be ideal.

Looking at the example from here: #1307 (comment)

That issue is closed so commenting here.

In this example, do the template and the 'entry' YAML need to be in the same repository? If not, how do you specify a template in a remote repository?

The requirement is to have a shared template, and then multiple projects with the 'entry' in their own repositories could reference it.

I'm also struggling to find definitive resource documentation for how to use templates in Azure Pipelines/DevOps - can someone point me to it?

@vtbassmatt
Copy link
Member

You can have templates in a different repo. You'll have to refer to the external repo in the resources section of your pipeline. Let's say you have a central repo, MyOrg/Templates, and you're building MyOrg/Service.

In MyOrg/Service, your YAML might look like this:

resources:
  repositories:
  - repository: templates
    type: github
    name: templates

steps:
- template: common_template.yml@templates

And in MyOrg/Templates, we'd expect to find common_template.yml at the root:

steps:
- script: ./build.sh
  displayName: Build
- script: ./test.sh
  displayName: Test

If there are things I can do to make the docs more clear, please feel free to open an issue at https://github.com/MicrosoftDocs/vsts-docs/issues. Thanks!

@timwebster9
Copy link

Thanks @vtbassmatt, that schema reference doc explains most things in detail. Just what I was looking for 👍

@wsmckenz
Copy link
Author

looks like you can now reference repos in another project. just tried this out and it works great.

Thanks!

@FilBot3
Copy link

FilBot3 commented Sep 2, 2020

Does this reference still need to be at the root of the template repository? I would like to have one repository for my templates and then split the release and build templates into their own folders.

@vtbassmatt
Copy link
Member

No, and I see how my comment a few years ago was misleading - but it never did 😁 It was only in that example where it looked at the root. You could just as easily have said:

resources:
  repositories:
  - repository: templates
    type: github
    name: templates

steps:
- template: some/nested/dir/common_template.yml@templates

And then it would look in some/nested/dir/ for common_template.yml.

@FilBot3
Copy link

FilBot3 commented Sep 3, 2020

I did something very similar with

resources:
  repositories:
    - name: templates
      type: git
      repository: MyProject/template-repo

steps:
  - template: templates/build/template-steps-build.yml@templates

and I was told that there was no YAML file at that location.

@vtbassmatt
Copy link
Member

Hmm... maybe I'm missing a leading /. I didn't think that was required, but I've been wrong before.

@FilBot3
Copy link

FilBot3 commented Sep 3, 2020

When I'm back in work I'll take a look, but it sounds like it needs to be

resources:
  repositories:
    - name: templates
      type: git
      repository: MyProject/template-repo

steps:
  - template: /templates/build/template-steps-build.yml@templates

@polavishnu4444
Copy link

Is there a way where I would want to reference a file path from the current yml location into the template from other repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants