Building a Clojure project on Travis CI that’s in a sub-directory of the repository

This wasn’t entirely obvious to me, so here goes.

First some very quick background. Travis CI is a wonderful, hosted continuous integration service, that is free and very easy to use for open source projects on Github.

I have a Clojure project on github that I want to build, but it’s in a sub-directory of its parent repository. It took me a few attempts to have Travis handle this correctly, but in the end it was simply a matter of doing the following in the .travis.yml file:


before_install: cd clojurenote

view raw

gistfile1.yml

hosted with ❤ by GitHub

What doesn’t work (and which I tried before realizing what’s going on) is using before_script, or putting the ‘cd‘ call within a script line itself. This doesn’t work because Travis runs ‘lein deps’ after before_install, but before before_script (and therefore before script) and thus fails if you haven’t already changed to the directory where your project.clj is by this point.

My full .travis.yml at time of writing is as follows:


language: clojure
lein: lein2
before_install: cd clojurenote
script: lein2 expectations
jdk:
– openjdk7
– oraclejdk7

view raw

gistfile1.yml

hosted with ❤ by GitHub