Import different files into different jobs

Hello,

I would like to know if there is a way to import travis configuration files to different job stages.

I mean, imagine I have a repo with the configuration_a.yml and another file with the configuration_b.yml

Would it be possible to generate a travis.yml file with this form:

jobs:
    include:
        - name: A
          import:
              - source: path/to/configuration_a.yml@main
        - name: B
          import:
              - source: path/to/configuration_b.yml@main

I do not see in the documentation if this is valid or not as it not appear where the imports should be placed.

Thanks for your help.

1 Like

I’m curious about the same thing. I’ve been using imports successfully in a number of projects, but have not found success with projects that define stages. I tried importing into a single stage, expecting that it would just work, but it does not get processed: https://travis-ci.org/travi-org/matt.travi.org-components/builds/625381469/config

I’ve tested that travis-yml (the app that implements build config validation and importing) crashes when you try to import at job level.

So currently, you can only import at global level.

And since jobs are a list, with existing merge modes, it’s impossible to change its entries, only prepend/append new ones or overwrite the existing list a a whole.

yep, this is the real kicker. while it would be inconvenient to have separate shareable configs for builds with stages vs not, but even that isn’t possible.