Using Jenkins for automation
Jenkins is an open-source continuous integration server. With it’s built-in flexibility and huge selection of plugins, Jenkins can be customized to fit into an organization’s development workflow easily no matter what type of project. At Via, we primarily uses it for automated deployments and as a launch pad to run common development tasks.
Automated project creation
All development projects at Via follow a common path from inception to production launch. All of these steps can be scripted and created as jobs in Jenkins. Additionally, with the handy MultiJob plugin, these individual jobs can be chained together into logical groups.
Let’s say we need to create a new WordPress project. What needs to happen?
- A git repository needs to be created and then be seeded with a fresh WordPress installation and our Silencio theme.
- A database and database user needs to be created.
- A new Virtualhost configuration needs to be created for Apache.
- Apache needs to be restarted.
Every one of these common tasks are created as individual jobs and then grouped together into a single MultiJob named “Create Project”. Now all a user needs to do is run a single job for perform all of these operations.
With Jenkins, we rarely need to ssh into a server in order to deploy code to a server environment.
Our development workflow assumes all code in the master branch of the project’s git repo is stable and deployable. Obeying this convention means we can consistently and reliably deploy code changes to any environment.
Here is an example of the steps involved when releasing code to a production environment.
- SSH into the server and cd to the directory containing the project.
- Run a ‘git pull’ to download the latest from upstream/master
- Tag the release in git
- Tag the release for our New Relic monitoring.
- Run automated tasks that are specific to the project.
- Compile a configuration file for the project, specific to the production environment.
- Run the Grunt configuration for the particular project (which typically includes compiling .css from .less files and then minifying .css and .js assets).
Keep it simple by rolling all of these steps into a single job!
Here are some other common tasks we’ve streamlined by creating jobs for them.
- Migrating WordPress content files between our different environments.
- Migrating databases between our different environments.
- Automatically run PHP_Codesniffer and JSCS against GitHub Pull requests (triggered by Mergeatron via GitHub)
- Creating a backup bundle of a GitHub repository.
- Archiving and (optionally) deleting a site from the server.
- Reverting a deployment to a previous tag.
- Open or close public access to a staging environment.
Bottom line, Jenkins allows us to keep our daily development options DRY and easy to execute from a central location. Built-in logging also allows us to easily diagnose unexpected problems and keep a history of when jobs are run.
- A wide variety of Jenkins tutorials from the official blog: https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins
- Setting up Continuous Integration and Continuous Deployment With Jenkins: http://code.tutsplus.com/tutorials/setting-up-continuous-integration-continuous-deployment-with-jenkins–cms-21511
Where Do We Start? The Technical Audit
By: Kim Clark on 3/15/2010
Any solid SEO program should begin with at technical audit of your website.Read More »
VIA Studio Joins Google Apps Authorized Reseller Program
By:Jason Clark on 3/25/2010
VIA Studio today announced it has become an authorized reseller of the Google Apps suite of communication and collaboration tools. VIA Studio provides setup, integration & support services for businesses and organizations using Google Apps.Read More »