Jenkins can be configured to invoke our test suite upon commit. This is very useful, because we can gear it to track our changes. Teams that use CI systems usually adopt an attitude of addressing CI failures immediately in order to keep the baseline functional.
Jenkins offers an almost unlimited number of features, such as retrieving the latest source from version control, packaging a release, running tests, and even analyzing source code. This recipe shows how to configure Jenkins to run our test suite against our shopping cart application.
java -jar jenkins.war
. It's important that no other applications are listening on port 8080.gturnquist$ mkdir /tmp/recipe46
gturnquist$ git init /tmp/recipe46 Initialized empty Git repository in /private/tmp/recipe46/.git/
gturnquist$ cp cart.py /tmp/recipe46/ gturnquist$ cd /tmp/recipe46/ gturnquist$ git add cart.py gturnquist$ git commit -m "Added shopping cart application to setup this recipe." [master (root-commit) 057d936] Added shopping cart application to setup this recipe. 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 cart.py
The following steps will show how to put our code under control and then run the test suite when we make any changes and commit them:
/tmp/recipe46/
.virtualenv
and runs the test suite.. /Users/gturnquist/ptc/bin/activate nosetests tests.py –with-nosexunit
You need to substitute the command to activate your own virtualenv, whether this is on Windows, Linux, or Mac, and then follow it with the command used to run the tests just like we did earlier in this chapter.
target/NoseXUnit/core/*.xml
, so that the test results are collected by Jenkins.gturnquist$ cp tests.py /tmp/recipe46/ gturnquist$ cd /tmp/recipe46/ gturnquist$ git add tests.py gturnquist$ git commit -m "Added tests for the recipe." [master 0f6ef56] Added tests for the recipe. 1 files changed, 20 insertions(+), 0 deletions(-) create mode 100644 tests.py
Jenkins provides a powerful, flexible way to configure continuous integration jobs. In this recipe, we configured it to poll our software confirmation management system once a minute. When it detects a change, it pulls a fresh copy of the software and runs our test script.
By using the NoseXUnit plugin, we generated an artifact that was easy to harvest with Jenkins. With a handful of steps, we were able to configure a web page that monitors our source code.
Jenkins has lots of options. If you examine the web interface, you can drill into output logs to see what actually happened. It also collects trends showing how long we have had success, when the last build failed, and more.
The answer is No. We used it in this recipe to quickly show how to install a Jenkins plugin from inside the web interface. To apply the plugin, we had to restart Jenkins.
Subversion and CVS are supported out of the box. Jenkins also has plugins supporting every major source code control system out there, so it should be easy to meet your needs.
In fact, there is support for social coding sites like GitHub and BitKeeper. Instead of using the Git plugin, we could configure our Jenkins installation to watch a certain GitHub account for updates.
We configured the polling with * * * * *
, which means once a minute. This is based on the format used to configure crontab files. The columns from left to right are:
3.144.97.216