In our previous blog post, we saw how to enable Selenium tests on a Django 1.4+ project. Now it's time to see how to integrate it with Jenkins!
This post assumes a Debian GNU/Linux environment, but you should not have much trouble adapting it to another Linux distribution. All requirements are listed in our initial blog post: Selenium, Python and Jenkins on Debian - 1/3.
First ensure that the latest version of the ShiningPanda Plugin, Xvnc Plugin, Violations Plugin and Cobertura Plugin are installed (check on Manage Jenkins > Manage Plugins > Installed page). If not, look for them in the Available tab and perform the installation (don't forget to restart Jenkins).
Then declare all the Python versions you want to test against with the Manage Jenkins > Configure System page (one shot configuration):
To add a Python version, search the Python section and click on Add Python. Then give the installation a name and enter its home folder (ie. PYTHONHOME).
This tutorial is based on the sample project described in Multi-browser Selenium tests with Django 1.4+. Our goal is to integrate this project within Jenkins.
First of all, create a New Job, enter its name (here djangotutorial) and select Build multi-configuration project before validating.
As usual, setup:
A display is required to run Selenium tests.
To start one, enable Run Xvnc during build in the Build Environment section.
To be able to install all the required packages, a Virtualenv Builder is recommended.
Click on Add build step in the Build section and select Virtualenv Builder.
Enter all required steps in the Command field:
Here is the full Command content:
pip install -r requirements.txt $PYTHON_EXE manage.py jenkins --selenium-driver=$BROWSER
Django-jenkins generates a lot of useful data for Jenkins in a reports folder.
To load them all, click on Add post-build action in the Post-build Actions section and select the following ones:
Finally save the configuration with the Save button.
Start a new build by clicking on Build Now, and wait for the results: