This feature was requested in e.g. https://stackoverflow.com/questions/46575415/can-i-multiply-options-in-matrix-include-with-the-env-option , https://github.com/travis-ci/travis-ci/issues/1519 .
The stumbling block seems to be that the root level of .travis.yml
is a hash table, so it can’t have duplicate keys, nor can it contain list entries.
However, YAML supports lists of lists :
env:
- - VAR1=foo
- VAR1=bar
- - VAR2=baz
- VAR2=xyzzy
and detecting a list of lists as opposed to a regular list is rather straightforward.
I would not allow both regular list entries and these nested ones, as well as deeper nesting, 'cuz that would rather be submatrices to build matrix – and unrelated complex problems will arise like if parent values should be inherited. For now, I’m only suggesting an equivalent to multiple env:
blocks.
cjw296
December 1, 2018, 10:52am
2
Not sure about the implementation you suggest, but I have the same problem so linked to this feature request from the SO question at https://stackoverflow.com/questions/46575415/can-i-multiply-options-in-matrix-include-with-the-env-option .
1 Like
Reviving this as this is something I would like as well. I have 3 different environment variables that I want to define and turn into a matrix.
And while I’m aware that I can do the below, this breaks principle of not repeating yourself.
ONE=a TWO=b THREE=c
ONE=b TWO=b THREE=c
ONE=c TWO=b THREE=c
As for implementation, I think the proposed list of lists is fine. And I think another option could be
env:
- axis:
- VAR1=foo
- VAR1=bar
- axis:
- VAR2=baz
- VAR2=xyzzy
The matrix expansion logic is allegedly in https://github.com/travis-ci/travis-yml . So you can create a PR against it to help things moving…