Build Imports in Travis
Sometimes you need a really dynamic configuration when setting up your pipeline. With imported configs, those configs can themselves include other configs, making this feature very composable (cyclic imports will be skipped). Let’s get started.
Getting started with Build Imports
When using Build Imports, remember that the main source of configuration for your build is the
.travis.yml file stored in the root directory of your project. So for example, here’s my root
language: ruby script: echo "It's Friday, which means blog day by Montana Mendy!" import: - ./.travis/all-the-rubies.yml - ./.travis/only-some-branches.yml
Now, let’s make a folder called in your project called
.travis, and in there, we’ll have a file called
all-the-rubies.yml, here’s the content of this configuration:
rvm: - 2.2 - 2.3
You’ll see the second imported configuration entitled
only-some-branches.yml in the
.travis folder in our project. Now here’s the content of that configuration file I made:
branches: only: - master - develop
So you can see above, there’s one master
.yml config, and you can think of the other two configurations as
child configurations. You can imagine with our Build Matrix feature and using Build Imports how flexible your builds can really be.
You’ve just used Build Imports in Travis like a pro! As per usual here’s an example repo I’ve made so you can follow it step by step and start using Build Imports.
As always, if you have any questions about Build Imports, please email me at email@example.com and I will assist you.