Wednesday, April 1, 2015

7 Ways to Optimize Jenkins

This article was sponsored by *CloudBee*s. Thank you for supporting the sponsors who make SitePoint possible!


The Jenkins Logo

Jenkins is a great tool for continuous integration and continuous delivery. In previous articles we’ve learned how to set up Jenkins for quality assurance and looked at one particularly useful plugin for supercharging your processes. In this article, we’ll guide you through seven ways to make sure you use Jenkins efficiently.


This article is based on a presentation given by Jenkins contributor Andrew Bayer at a 2014 Jenkins User Conference and is adapted here with permission.


1. Make sure Jenkins is stable and working correctly


Jenkins releases new versions frequently. It’s recommended to always use the latest Long-Term Support (LTS) release and avoid the updates in-between. The LTS release is tested by the Jenkins project.


The same kind of rule also applies to plugins. They don’t have LTS releases, but many updates can occur. In general you should stick to the rule: If it’s working, don’t update it. New updates can make features unstable. Furthermore, any given plugin may behave differently than expected.


Also make sure you create backups of your Jenkins server. You could back-up all data, but that will cost you a lot of time and resources. Instead, you could decide to only back-up your config files through scripts like this.


2. Don’t fill Jenkins with bloat


There are a couple of simple things you can do to avoid being the owner of a bloated Jenkins installation:




  1. If you have a lot of teams or projects, you might create multiple Jenkins masters. For example, you could create a master for PHP projects and a separate one for Android projects. Doing this will ensure that changes don’t affect all projects and that you have only the plugins needed on a specific master for each project.




  2. Break your jobs into multiple smaller jobs. Nothing is more annoying than a long build failing somewhere at the end. If you break your jobs into smaller jobs, you can easily restart one if it fails. The Workflow plugin is useful for this purpose. If you’re interested in a more in-depth explanation of the Workflow plugin, have a look at our recent product review.




3. Automate Jenkins


Jenkins comes with an integrated script console, allowing you to execute commands on the server. It’s a handy tool to debug Jenkins or to find information you need.


An interesting plugin is the Scriptler plugin. With this plugin, you can save your favorite scripts for later reuse. You can also find an online script catalog here with predefined scripts like clearing the job queue.


For each build, you can also write your own build steps in the Groovy language. This gives you more flexibility within your job, but it also means you’ll need to be more careful, because it gives you more control. You can also run scripts from the Scriptler catalog as a build step.


If you have a lot of projects, consider generating jobs automatically. Jenkins comes with a great REST API and a CLI tool to create new jobs. You can also dive into plugins like Workflow which we discussed recently to automate certain parts of the process, or the Cloudbees Templates plugin that let’s you easily generate jobs from a pre-defined job skeleton.


4. Carefully consider your plugins


Jenkins has a rich collection of plugins; it’s easy to get lost in the huge number that are available. It’s important to decide if you really need a given plugin. Plugins can potentially break functionality within Jenkins in places you might not expect. They can also slow down your build jobs. Make sure to pick the right plugin for the right job. Don’t just install them if you don’t really need them.


Keep track of your list of plugins and uninstall any plugins which are no longer used. This will help to keep Jenkins in good shape and free of bloat.


Also remember that some plugins come with global configuration settings. Don’t forget to check the global configuration after installing a plugin, as the default settings may not be what you want and could lead to unexpected behavior.


Continue reading %7 Ways to Optimize Jenkins%




by Peter Nijssen via SitePoint

No comments:

Post a Comment