Windows | Linux
VisualStudio.com
http://msdata.visualstudio.com
I would love it if I could use anchors in my yml file to enable some code reuse. For example:
&REPEATED_TASK { displayName: foo, inputs: bar }
...
- task:
<<: *REPEATED_TASK
Thanks!
I agree. It's something we want to enable.
Note templates are currently supported and allow for code reuse.
It's interesting that in your example you used ... are you suggesting to allow for a separate document where you can define anchors, and then your process document where you can reference the anchors defined in the separate document?
Thanks for the tip on the templates - I wasn't aware of them and they are in fact a better fit for my needs: https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-templates.md
The ... just referred to space in the same .vsts-ci.yml document. Thanks again!
Could this be reopened? I just set up VSTS for the first time and was very surprised they don't work. They work in every other CI provider I've used before (Travis, Circle, Buildkite). Having to write an extra template file with parameters just to reuse simple structures/values is cumbersome, and with the parameterization it's harder to typecheck against a schema in an editor. If I needed parameterization, I would prefer generating the config dynamically in an actual programming language (like Buildkite allows you to). It's also a bad first user experience because you don't find out they are not supported until you committed the YAML and triggered another build - too many of these failed builds because of invalid config cause frustration.
I really wonder _why_ they are not supported? What YAML parser does not support them?
Just to chime in that supporting anchors would be very useful and allow for quick and elegant solutions to simple problems. Here is an example of a simple definition that runs the same steps+matrix on Linux and MacOS. This is also possible with templates, but requires an additional file (plus learning about the template feature, which seems a bit of an overkill for many common cases where plain YAML would suffice).
it would also be very useful for things other than tasks and jobs (which templates support)
dependencies: &dependencies
branches:
include:
- master
- release/*
paths:
include:
- src/App1/
- src/App2/
- src/SharedCodebase1/
- src/SharedCodebase2/
trigger:
batch: true
<<: *dependencies
pr:
<<: *dependencies
@samuel-begin I worked around that by creating a dummy job (a job with no steps that depends on all of them, and specifies pool: server so that it won't waste time spinning up an agent), and is depended on in place of the list. A job like that only takes about one second.
Are there any plans for enabling anchors and references in azure pipeline yaml configuration files?
Most helpful comment
Could this be reopened? I just set up VSTS for the first time and was very surprised they don't work. They work in every other CI provider I've used before (Travis, Circle, Buildkite). Having to write an extra template file with parameters just to reuse simple structures/values is cumbersome, and with the parameterization it's harder to typecheck against a schema in an editor. If I needed parameterization, I would prefer generating the config dynamically in an actual programming language (like Buildkite allows you to). It's also a bad first user experience because you don't find out they are not supported until you committed the YAML and triggered another build - too many of these failed builds because of invalid config cause frustration.
I really wonder _why_ they are not supported? What YAML parser does not support them?