Jenkins is one of the best Continuous Integration Server out there in the market with over 1000 plugins. Back in the days, creating a Jenkins job is as easy as navigating through some pages selecting the type of job, source code management tool, build tool etc. but, as time progressed, we entered an era of “Things-as-Code” or “Things-as-Config” started gaining popularity. Provisioning “Things-as-Code” or “Things-as Config” has its own benefits like Zero-touch provisioning, Version controlling your configurations, creating consistent systems etc. In this article we will take a look at the Jenkins Configuration as Code Plugin.

Jenkins came up with its version of “Jenkins-pipeline-as-code” with the release of version 2.0. The pipeline as code enabled us to configure entire job flow right in our IDE, also opened up a lot of features that would have otherwise been almost impossible or tedious to implement using freestyle jobs. One example could be designing a job spanning over multiple nodes which feels like a breeze using pipeline jobs but is an upstream-downstream hell(pardon my language) using freestyle jobs. Backing up our job is as easy as adding our Jenkinsfile to source control. As pipeline as code eased up the management work on Jenkins jobs, Docker made setting up the Jenkins infrastructure very easy. However, a manual touch is always needed in the Jenkins global configuration.

Here are a few things we will touch upon in this article:

A typical Jenkins setup flow

Here is a simple flow of steps involved in setting up a Jenkins instance:

Jenkins Setup Flow

Jenkins Setup Flow

In simple words, most of the configurations(if not all) that goes under “Manage Jenkins” requires manual setup, some of these configurations include,

  • Setting up security
  • Configuring LDAP settings
  • Setting up tool installations eg: GIT, ANT, Sonar etc.
  • Any custom global settings for plugins installed eg: kubernetes plugin

Is Jenkins config as code really possible?

Now, let’s try to answer the most important question in context to this article. As previously discussed, Jenkins pipeline as code and Docker to some extent help us take a step closer to a “stateless” Jenkins server. Even most of the administrative tasks mentioned above can be automated using initscripts. However, it requires a deeper understanding of Jenkins plugins and expertise in groovy.

Configuration as code is not a new concept in Jenkins, it’s just not as easy to achieve and once achieved, maintain.

‘Jenkins Configuration as Code’ plugin hands-on

Let’s look at the high-level functioning of the Jenkins Config as Code Plugin using a simple example.

#continuous integration #devops #ci #configascode #docker #jenkins

Jenkins Configuration as Code : step towards stateless CI - CodeBabel
1.45 GEEK