Continuous Integration Setup with Jenkins for a Node.js Project – Part 1

For continuous integration for Node.js projects, there’s Travis and there’s Wercker.  But sometimes, you need to have your continuous integration tool hosted on your own server, and that is where Jenkins comes at an advantage.  It’s been around way before Travis and Wercker, and some of you may remember it as Hudson.  Also, Jenkins is free for both public and private repos.  Furthermore, it has tons of plugins such as unit testing, code coverage, Javascript linting/hinting, etc etc.  On the downside, Jenkins is the hardest to set up among the three, and that is why I wrote this post.  We’ll learn how to set up continuous integration with Jenkins for a Node.js project.  In the first part of this series, we will install Jenkins on our own server, whether it be on Heroku or your own web host or what have you.

There are 3 files to place on your server – jenkins.war, pom.xml, and Procfile, each of them being on the same directory level on your server.  The jenkins.war can be downloaded from the Jenkins site at https://jenkins-ci.org/.  The pom.xml is very basic and has what the server needs to run the war.  The Procfile contains the necessary commands to run the jenkins.war.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.example</groupId>
 <version>1.0-SNAPSHOT</version>
 <artifactId>example-ci</artifactId>
</project>

Procfile

# Only listen on http; disable ajp and https
web: java -jar jenkins.war --httpPort=$PORT --ajp13Port=-1 --httpsPort=-1

The files can be found at – https://github.com/melkybee/jenkins-ci.

Of course, this is just one way to install Jenkins on your server.  Alternate ways to install it on your server (i.e., Ubuntu/Debian) can be found at the Jenkins website, https://jenkins-ci.org/.

At this point, Jenkins should be installed and running on your server.  You’ll see the default Jenkins dashboard with the mustache guy at the top left.  In part 2, we’ll set up all the basic configurations necessary in Jenkins and installing and integrating with GitHub.

Leave a Reply

Your email address will not be published. Required fields are marked *