How To Add Free Continuous Integration Your JavaScript Project With TravisCI

In this tutorial, you will learn how to create a free continuous integration pipeline into your Github hosted Javascript project using TravisCI.  We all know that having a set, despite all the information out there, a lot of teams that I work with never bother getting started.  The number one cause is the team doesn't have enough time, or knowledge to get started.  This isn't true.  Within around 15 minutes you can add a build pipeline to your project; sounds good then read on.

What Is Travis CI

Travis CI is a continuous integration tool, it integrates into Github easily and will run your unit tests on every commit to your repo and email you the results. The best part... it's free for open source projects!  To get started you will need to create an account with Travis CI here.  

Sign in with your Github account and head over to the repositories page, 'https://travis-ci.org/account/repositories'

From this page, you will see a list of all your public Github repos.  To start a CiCd pipeline, simply click the enabled button:

Before Travis will start triggering on when you commit, you will need to add a config file into your solution.  In your Javascript project in your root folder create a file called '.travis.yml'.  In here you will need to create a file like this:

language: node_js
node_js:
  - stable
install:
  - npm install
script:
  - npm test

If you commit your new change and push it, you should see a build trigger in Travis! It really is that easy to set-up a CiCd pipeline into your Javascript projects. 

The last thing that I recommend you do is add the state of your build to your Github repo.  You may have noticed those cool little badges on some peoples Git repos, like this one:

Adding this to your repo is simply a matter of creating a readme file and adding some config into it.  Log into Travis, go to the repo page and find your project and click the setting button.

Next, click the build icon against your project:

From the pop-up, ensure that markdown is selected from the drop-down. 

Next, copy the next at the bottom and add that to your readme file.  Commit and push it and you should now see the build status when you view your readme in your repo.  

submit to reddit

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top