In this post i will explain how to integrate Jenkins with Nodejs.
Why Jenkis? Because it’s the most popular CI.
What is Jenkins?
Jenkins is a continuous integration application. The main features are:
- Building/testing software projects continuously
- Monitoring executions of externally-run jobs
More information here.
- Easy to learn
- Open Source
- Good Documentation & Tutorials
- Plugins for everything
- 404: Not Found
Setup the Environment
After the installation to check if everything is alright go to http://localhost:8080 by default is in port 8080. If everything is fine we should see this. (This is the new layout)
Now we should install the GIT plugin. To install plugins go to “Settings” menu and after “Plugins”.
After the installation we need to configure it. In the jenkins configuration, in the GIT section it’s necessary to put the path to the GIT CMD executable.
Job is a runnable task that is controlled/monitored by Jenkins. We are creating a job for our project.
1 – Create the Job
2 – Configure the SCM (Source Control Management)
In our case we are using GIT but Jenkins also support SVN and mercurial.
3 – Setup the build process
I created a npm task “jenkins”, this task runs an Grunt task. The task consist to running the tests and execute the JsHint to check code metrics.
4 – Post Build Actions
Here is the “key”, after the build are created two reports, one for tests and another for the jshint errors. The test report is compatible with JUnit test format, so the Jenkins can interpret. If all the tests are successful the build result is a success otherwise is a failure.
6 – JsHint Plugins
In the job page we can see the jshint report results.
Now you can integrate your nodejs projects in Jenkins 🙂