Use different .travis.yml's for different packages within the repo

Hello there,

I have a problem using travis with lerna (I have two packages inside my repo).

My repo - - it’s made with lerna.js and I have two packages: frontend and backend. I would like to start with frontend, so that anytime there is a pull request made which touches frontend code, job is triggered and it will run unit tests and build.

travis.yml file - it’s created and merged into master branch. It’s located in frontend/ package.

My problem - I checked the documentation of travis and I would like to set up a pipeline which will be triggered anytime pull request for “frontend” package is created.

Should it be one travis.yml file for each of the packages? Or should it be only one for one repo? If yes, then how can I parametrize it so that it can run tests for frontend package? For example, I would like to run the job for this package only when branch has name starting with “frontend/”.

There’s only one controlling .travis.yml per repo. It needs to be in its root.

You are free to invoke any custom logic depending on what specifically a commit has changed and whatnot.

Travis aso exposes some information about the properties of the build via environment variables.

Thanks for reply. Can you provide an example how can I parametrize job?

For example - one set of steps is run when pull request is made from branch frontend/, another set is run when base branch is backend/

For example:

- if [[ $TRAVIS_BRANCH == frontend/* ]]; then ./; fi
- if [[ $TRAVIS_BRANCH == backend/* ]]; then ./; fi