-
Notifications
You must be signed in to change notification settings - Fork 941
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
design: each expression #2
Conversation
@chrisrpatterson |
pool: ${{ job.pool }} | ||
workspace: ${{ job.workspace }} | ||
steps: ${{ job.steps }} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean this could be written as such (simpler, no need to explicit list out everything)
parameters:
jobs: []
jobs:
- job: CredScan # Cred scan first
pool: MyCredScanPool
steps:
- task: MyCredScanTask@1
${{ each job in parameters.jobs }}
- ${{ each pair in job }}: # Insert all properties other than "steps"
${{ if ne(pair.key, 'dependsOn') }}:
${{ pair.key }}: ${{ pair.value }}
${{if job.dependsOn}}
dependsOn:
- ${{ CredScan }}
- ${{ job.dependsOn }}
${{ if not(job.dependsOn) }}:
dependsOn:
- CredScan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
Could we do this in variables:
NODE_VERS: ['6.x', '8.x', '10.x']
TS_VERS: ['2.8', '2.9', '3.0']
strategy:
matrix:
$[ each nodeVer in variables.NODE_VERS ]:
$[ each tsVer in variables.TS_VERS ]:
$[ concat(nodeVer, '_', tsVer) ]:
NODE_VERSION: $[ nodeVer ]
TS_VERSION: $[ tsVer ]
steps:
- script: echo Node $(NODE_VERSION) against TypeScript $(TS_VERSION) It's not the prettiest way to create a matrix, for sure. I predict people will try to do it, though, and the same thing is even grosser if you're forced into a template for it :) |
@vtbassmatt I would much rather have a specific function for doing a cross product a variable array and apply some exclusions. Seems cleaner. |
my comments got deleted, eh? |
@4c74356b41, looks like your comments were added as a part of mmitche's review, which was resolved but is still available. |
can you provide a link, i cant seem to find those. thanks. @chcosta |
ok, why is it resolved than? I dont mean to say I'm the most important guy out here, but comments are there for a reason. I work with these yaml definitions and they are pretty horrible for anything remotely clever. why cant I use concats? or other common string\object manipulation functions? |
mmitche's review was resolved (likely via a GitHub push). If you have feedback, you should do your own review or start another comment thread so that the topics don't get lost in the mix. |
@vtbassmatt , @chrisrpatterson: Is there a way to create a cross product matrix today? If not, should a separate issue be filed for this? |
@mikeharder there isn't a command for cross-product matrix. Feel free to file it; it's on our minds but not highly prioritized right now. |
What is meant by "cross-product matrix"? @vtbassmatt , is that the same request as https://dnceng.visualstudio.com/7ea9116e-9fac-403d-b258-b31fcf1bb293/_workitems/edit/59 or a different scenario? |
@chcosta: It looks like https://dnceng.visualstudio.com/7ea9116e-9fac-403d-b258-b31fcf1bb293/_workitems/edit/59 is the same as #4. The ability to use a variable (in this case from a matrix) to set By "cross-product matrix", I mean the scenario where you want to use the strategy:
matrix:
Linux_Python36:
VM_IMAGE: 'ubuntu-16.04'
PYTHON_VERSION: '3.6'
Linux_Python37:
VM_IMAGE: 'ubuntu-16.04'
PYTHON_VERSION: '3.7'
Windows_Python36:
VM_IMAGE: 'vs2017-win2016'
PYTHON_VERSION: '3.6'
Windows_Python37:
VM_IMAGE: 'vs2017-win2016'
PYTHON_VERSION: '3.7' While this isn't too bad with a small number of dimensions and a small number of variables in each dimension, it can quickly become unmaintainable as the dimensions and variables grow. It would be nice if there was a way to express this more succinctly, something like: strategy:
cross-product:
PYTHON_VERSION: [ '3.6', '3.7' ]
VM_IMAGE: [ `ubuntu-16.04`, `vs2017-win2016` ] Tracking issue: #20 |
We've shied away from cross-product for two reasons:
Notwithstanding the above, I'm open to the concept. Let's start a separate issue about it and have the conversation there. This PR's about |
@vtbassmatt: Separate issue for cross-product: #20 |
f52fb06
to
7005acc
Compare
@ericsciple, if my solution has multiple projects, I would like to loop through each project and publish build artifacts task: PublishBuildArtifacts@1 Thanks, |
Can you add two tasks?
|
@ericsciple I could always do that but there may be a situation where there are multiple projects in one solution, some may have 5, some may have 3 projects. It would make it easier if I could loop through each project that is defined as an array in the parameter. parameters; Thanks UPDATE: How do I pass the project parameters? parameters; |
@ericsciple any update as to how to pass the project parameter? I am using the each each expression but getting an array can not be converted to a string error. |
@andrewsuiter sorry, my example was wrong. Here is a better example: # my-template.yml
parameters:
steps:
- ${{ each project in parameters.project }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish ${{ project }}
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ project }}.zip' # ci.yml
steps:
- template: my-template.yml
parameters:
- test1
- test2 That way, one task is added for each item in the array |
ok great, I will give it a shot, thanks for the help! |
@ericsciple That works perfect, exactly what I was looking for, much appreciated! |
@ericsciple Is there any way to use nested within # my-template.yml
parameters:
steps:
- ${{ each pf in parameters.pf }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish ${{ pf.rid }} ${{ pf.output }}'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ pf.output }}.zip' # ci.yml
steps:
- template: my-template.yml
parameters:
- windows:
rid: 'win-x64'
output: 'Foo.exe'
- macos:
rid: 'osx-x64'
output: 'foo' |
Hi Team Code: variables:
I want to use/pass MyVariableName to template.yml where i want to iterate array parameters: steps:
|
@ericsciple - FYI the quote is missing in the displayName of your example: |
No description provided.